Having troubles sending email throw php on centos 6.7 with cpanel installed. I assume the problem with Mail.php reference path but I don't know how to correct it. The mail.php file located here: /home/userfolder/php/Mail.php (I have installed the following PEAR packages: Auth_SASL, Mail, Net_SMTP, Net_Socket) The error which I get is: Fatal error: Class 'Mail' not found in home/userfolder/public_html/_sendmail.php on line 14
<?php
ini_set("include_path", '/home/userfolder/php:' . ini_get("include_path") );
$from = "Sandra Sender <[email protected]>";
$to = "Ramona Recipient <[email protected]>";
$subject = "Email";
$body = "Hi,\n\nHow are you?";
$host = "mail.domain.com";
$username = "username";
$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("<p>" . $mail->getMessage() . "</p>");
} else
{
echo("<p>Message successfully sent!</p>");
}
?>
Add into begin of file
require_once dirname(dirname(__FILE__)) . '/Mail.php';