Phpmailer: Error: AUTH not accepted from server: 503 AUTH command used when not advertised

Created on 7 May 2018  路  8Comments  路  Source: PHPMailer/PHPMailer

Hi, I have an issue that sometimes emails in sent very slow. I turned on the debug mode and it returns

SMTP -> ERROR: EHLO not accepted from server: 501 Syntactically invalid EHLO argument(s) 
<br />SMTP -> ERROR: HELO not accepted from server: 501 Syntactically invalid HELO argument(s)
<br />SMTP -> ERROR: AUTH not accepted from server: 503 AUTH command used when not advertised

But after I investigated more, I found in SMTP logs it showed Connecting to aspmx.l.google.com [209.85.201.27]:25 ... failed: Connection timed out (timeout=5m)

I also checked port 25 by echo QUIT | openssl s_client -starttls smtp -crlf -connect smtp.gmail.com:25. Sometimes it cannot connect to the server and returns Connection Timed Out.

Here is my SMTP config:

port = 25
$mail->IsSMTP(true); // SMTP
$mail->SMTPDebug = 1;
$mail->SMTPAuth   = true; 

Does anyone has any idea how to fix it?
Thanks a lot

Most helpful comment

For people who have similar issues: Finally we found it was AWS EC2 that blocked SMTP Port 25 and as it said on EC2 Port 25 Throttle, Amazon EC2 throttles traffic on port 25 of all EC2 instances by default. We start to use AWS SES and it is working fine till now.

Marcus, thanks so much for your help!

All 8 comments

Connection timed out means that you have a network problem. That's nothing to do with your code.

AUTH command used when not advertised is because you told it to use auth without encryption, which gmail doesn't support. If you had set SMTPDebug = 2 as the docs suggest, you would see what the server is saying.

Try again, basing your code on the gmail example provided.

@Synchro Thanks for your reply. Is there any way to check if the network connection timeout issue is caused by ISP or Gmail?

Yes - follow the advice in the troubleshooting guide, which tells you how to diagnose such problems.

@Synchro https://github.com/PHPMailer/PHPMailer/wiki/Troubleshooting#testing-ssl-outside-php I am testing this part and get connect timeout issue so is the problem caused by ISP?

Very likely, yes. If it doesn't work on a command line, it's unlikely to work from PHP either.

@Synchro Is it possible that it was Gmail/Hotmail that blocked my connection, not ISP? Sorry for so many questions.

No. If they were blocking you from sending email (for example if they think you're a spam source), they would allow you to connect, but give you SMTP-level errors telling you that they won't accept mail from you (and probably why as well). The net result is that openssl or telnet tests would still work. ISPs blocking outbound SMTP is extremely common - for example GoDaddy does it. You can test further by attempting to connect to other public mail servers such as AOL or office365.

For people who have similar issues: Finally we found it was AWS EC2 that blocked SMTP Port 25 and as it said on EC2 Port 25 Throttle, Amazon EC2 throttles traffic on port 25 of all EC2 instances by default. We start to use AWS SES and it is working fine till now.

Marcus, thanks so much for your help!

Was this page helpful?
0 / 5 - 0 ratings