I am working on sending out SMTP relay email's using Gmail as my server using Pear Mail package in PHP. I have installed Pear package using YUM. Also I have located the path for pear_dir and included the same in the php.ini file. How ever when I try to run my .php file for the mail (code attached below) the file does not run.. Any pointers as to what I am doing wrong here?
<?php
require_once "Mail.php";
$from = "Sandra Sender <xyx@gmail.com>";
$to = "Ramona Recipient <xyz@gmail.com>";
$subject = "Hi!";
$body = "Hi,\n\nHow are you?";
$host = "ssl://smtp.gmail.com";
$username = "xyz@gmail.com";
$password = "XXXXXXXXXXXX";
$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>");
}
?>