Howdie do,
I have a very simple script that is just suppose to email a confirmation email to users. However, I keep getting the following error:
authentication failure [SMTP: Failed to write to socket: not connected (code: 250, response: Hello localhost [127.0.0.1] SIZE 52428800 8BITMIME PIPELINING AUTH PLAIN LOGIN STARTTLS HELP)]
The script is below. Pear mail has been installed. And yea, the password is correct, but I didn't place it in the script on here. Has anybody seen this error before?
function send_email($from, $to, $subject, $body)
{
require_once "Mail.php";
global $debug;
$host = "localhost";
$username = "user";
$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) && $debug)
{
echo("<p>" . $mail->getMessage() . "</p>");
}
}
Edit:
The exim_mainlog is actually displaying this when the call goes through:
2013-09-06 15:50:51 SMTP connection from [127.0.0.1]:59845 (TCP/IP connection count = 1) 2013-09-06 15:50:51 SMTP connection from localhost [127.0.0.1]:59845 lost
Ok, so I totally gave up on Pear::Mail and just converted the entire script to PHP_Mailer.
It's now working with no issue
function send_email($from, $to, $subject, $body)
{
ini_set("include_path", ".:/home/user/public_html/PHPMailer_v2.0.4/");
require_once("class.phpmailer.php");
global $debug;
$mailer= new PHPMailer();
$mailer->IsSMTP();
$mailer->Host = 'localhost';
$mailer->SMTPAuth = true;
$mailer->Username = "email";
$mailer->Password = "*******";
$mailer->FromName = "User";
$mailer->From = "email";
$mailer->AddAddress($to);
$mailer->Subject = $subject;
$mailer->Body = $body;
if(!$mailer->Send())
{
//echo "Message was not sent";
echo "Mailer Error: " . $mailer->ErrorInfo;
exit;
}
}