Super User is a question and answer site for computer enthusiasts and power users. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

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



$mail = new PHPMailer();

$mail->Host = "";
$mail->SMTPAuth = true;
$mail->Username = "";
$mail->Password = "password";

$mail->From = "";
$mail->FromName = "From Name";


$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";

   echo "Message could not be sent. <p>";
   echo "Mailer Error: " . $mail->ErrorInfo;

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?


***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??

I tried swiftmail and it works fine :-) so I am dumping PHPMailer

share|improve this question

You might try requesting a TLS connection like this:

$mail->SMTPAuth   = true;
$mail->SMTPSecure = "tls";

this question/answer on SO has more information. Including the recommendation to use the php PEAR library instead of phpmailer.

share|improve this answer
Hi Jeremy. I tested the tls option and I got the followinf error: Language string failed to load: tls Message could not be sent. Mailer Error: Language string failed to load: tls Then, if I try right after, it works! I'll give it a try to Pear. Thanks! – Javier Jun 2 '12 at 10:04
okay great. You updated your answer to indicate you tried swiftmail. You should post that as an answer and then accept it (it's okay to answer your own question ... in fact, it's encouraged here) – Jeremy W Jun 2 '12 at 14:44

I am not sure if the problem was the server or PHPMailer, but I tried Swiftmail and it worked fine. I usually like to know WHY something is not working but I can't find the problem and the technical service is as lost as I am. So I'm just going to stick to Swiftmail from now on for my projects.

Thanks for the help!

share|improve this answer
use wireshark see what that shows – barlop Nov 1 '15 at 23:55

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .