SMTP authentication error using PHP
Posted on 2010-08-25
I'm trying to use PHP to send a response when needed from my website with the appropriate company email address and keep getting errors. Originally the emails were not authenticated but then certain users where not receiving them. I've since tried added authentication and still no luck. I put the code below and the errors.
I've also tried port 465 which is the alternate smtp port provided by the hosted exchange service. I've verified smtp relay is active. I've also verified I'm getting a response by telneting to both ports of my smtp server.
$mail = new PHPMailer();
$mail->IsSMTP(); // set mailer to use SMTP
$mail->Host = "my.mail.server:25"; // specify main and backup server
$mail->SMTPAuth = true; // turn on SMTP authentication
$mail->Username = "email@example.com"; // SMTP username
$mail->Password = "mypassword"; // SMTP password
$mail->From = "firstname.lastname@example.org";
$mail->FromName = "Me";
$mail->WordWrap = 50; // set word wrap to 50 characters
$mail->IsHTML(true); // set email format to HTML
$mail->Subject = "Here is the subject";
$mail->Body = "This is the HTML message body <b>in bold!</b>";
echo "Message could not be sent. <p>";
echo "Mailer Error: " . $mail->ErrorInfo;
SMTP Error: Could not authenticate. Message could not be sent.
Mailer Error: SMTP Error: Could not authenticate.