I am using PHPMailer to send a basic form to an email address but I get the following error:
SMTP Error: Could not authenticate. Message could not be sent.
Mailer Error: SMTP Error: Could not authenticate.
SMTP server error: VXNlcm5hbWU6
The weird thing is that if I try to send it again, IT WORKS! Every time I submit the form after that first error it works. But if I leave it for a few minutes and then try again I get the same error again.
The username and password have to be right as sometimes it works
fine. I even created the following (very basic) script just to test it and I got the same result
<?php
require("phpmailer/class.phpmailer.php");
$mail = new PHPMailer();
$mail->IsSMTP();
$mail->Host = "smtp.host.com";
$mail->SMTPAuth = true;
$mail->Username = "
[email protected]";
$mail->Password = "password";
$mail->From = "
[email protected]";
$mail->FromName = "From Name";
$mail->AddAddress("
[email protected]");
$mail->AddReplyTo("
[email protected]");
$mail->IsHTML(true);
$mail->Subject = "Here is the subject";
$mail->Body = "This is the HTML message body <b>in bold!</b>";
$mail->AltBody = "This is the body in plain text for non-HTML mail clients";
if(!$mail->Send())
{
echo "Message could not be sent. <p>";
echo "Mailer Error: " . $mail->ErrorInfo;
exit;
}
echo "Message has been sent";
?>
I don't think this is relevant, but I just changed my hosting to a Linux shared server. Any idea why this is happening?
Thanks!
***UPDATED 02/06/2012
I've been doing some tests. The results:
I tested the script in an IIS server and it worked
fine. The error seems to happen only in the Linux server.
Also, if I use the gmail mail server it works
fine in both, IIS and Linux.
Could it be a problem with the configuration of my Linux server??