I have a php script that is going to be a cron job and it was working fine until I added the email script I have been using.
I have used the email script all over the site before but when I try and run the cron job using it from the command line it fails.
The mail script looks as followed
<?php
require_once "Mail.php";
function sendMail($to, $from, $subject, $message) {
$no_errors = true;
$host = "ssl://smtp.server.com";
$port = "465";
$username1 = "username";
$password = "password";
$headers = array ('From' => 'myfromemail@myemail.com',
'To' => $to,
'Subject' => $subject);
$smtp = Mail::factory('smtp',
array ('host' => $host,
'port' => $port,
'auth' => true,
'username' => $username1,
'password' => $password));
$mail = $smtp->send($to, $headers, $message);
if (PEAR::isError($mail)) {
$no_errors = false;
echo $mail->getMessage();
} else {
$no_errors = true;
}
return $no_errors;
}
?>
If I comment out the include send_mail.php it works fine but doesn't send email.
Any ideas?