I'm currently attempting to setup a mail form using PEAR::Mail so I can take advantage of sending mail via an authenticated SMTP server. I currently have the following modules installed:
* Archive_Tar (1.3.5)
* Auth_SASL (1.0.3)
* Console_Getopt (1.2.3)
* Mail (1.1.14)
* Net_SMTP (1.4.1)
* Net_Socket (1.0.9)
* PEAR (1.9.0)
* Structures_Graph (1.0.3)
* XML_Util (1.2.1)
The above was installed in the following order PEAR first then Mail (the other modules came with them). I then tried to execute the following code from /public_html/:
Code:
<?php
require_once "../php/Mail.php";
$from = "Test <sender@example.com>";
$to = "SteRiley <email@email.com>";
$subject = "This is a test message";
$body = "Did this work?";
$host = "ssl://mail.mydomain.com";
$port = "465";
$username = "myusername";
$password = "mypassword";
$headers = array ('From' => $from,
'To' => $to,
'Subject' => $subject);
$smtp = Mail::factory('smtp',
array ('host' => $host,
'port' => $port,
'auth' => true,
'username' => $username,
'password' => $password));
$mail = $smtp->send($to, $headers, $body);
if (PEAR::isError($mail)) {
echo("<p>" . $mail->getMessage() . "</p>");
} else {
echo("<p>Message successfully sent!</p>");
}
?>
However this returns the following error:
Code:
Warning: include_once(Net/SMTP.php) [function.include-once]: failed to open stream: No such file or directory in /home/steriley/php/Mail/smtp.php on line 206
Warning: include_once() [function.include]: Failed opening 'Net/SMTP.php' for inclusion (include_path='.:/usr/lib/php:/usr/local/lib/php') in /home/steriley/php/Mail/smtp.php on line 206
Fatal error: Class 'Net_SMTP' not found in /home/steriley/php/Mail/smtp.php on line 210
/php/Mail/smtp.php on line 206 is set to include_once 'Net/SMTP.php'; I assume something clever goes on to path it to the correct place? I've tried amending it to include_once '../Net/SMTP.php'; but this didn't help.
This is the first time I've attempted to use PEAR to it could be a n00b error, where am I going wrong?