Cannot send email via php script

Avatar
  • Answered
Here is the script: "; $subject = "Test Php script"; $body = "Lorem ipsum dolor sit amet, consectetur adipiscing elit..."; $host = "mail.############.com"; $username = "james@############.com"; $password = "PASSWORD"; $headers = array('From' => $from, 'To' => $to, 'Subject' => $subject); $smtp = Mail::factory('smtp', array ('host' => $host, 'auth' => true, 'username' => $username, 'password' => $password)); $mail = $smtp->send($to, $headers, $body); if ( PEAR::isError($mail) ) { echo("

Error sending mail:
" . $mail->getMessage() . "

"); } else { echo("

Message sent.

"); } ?> Here is the Error: ###@######.com [~/AmIUpNow]# php -f test.php Warning: include_once(Net/SMTP.php): failed to open stream: No such file or directory in /usr/lib/php/Mail/smtp.php on line 206 Warning: include_once(): Failed opening 'Net/SMTP.php' for inclusion (include_path='.:/usr/lib/php:/usr/local/lib/php') in /usr/lib/php/Mail/smtp.php on line 206 Fatal error: Class 'Net_SMTP' not found in /usr/lib/php/Mail/smtp.php on line 210
Avatar
JacobIMH
Hello bluefish001, The error that you're receiving: Warning: include_once(Net/SMTP.php): failed to open stream: No such file or directory in /usr/lib/php/Mail/smtp.php on line 206 Is stating that your /usr/lib/php/Mail/smtp.php file on line 206 is trying to include the Net/SMTP.php script, and the server can't find that file in that particular location. It sounds like you might want to install a PEAR module, and in this case Net_SMTP. You can do this in cPanel by clicking on PHP PEAR Packages under the Software/Services section, and then searching for Net_SMTP. Although you might also find it easier to just use phpMailer instead also. Please let us know if you had any further questions at all. - Jacob