Skip to content
Advertisement

SMTP Error: Could not authenticate. Message could not be sent. Mailer Error: SMTP Error: Could not authenticate

When I trying to send a email using PHP SMTP email server, following error has occurred.

JavaScript

Mailer Error: SMTP Error: Could not authenticate.


Following is my code that I have used.

JavaScript

}

How can I fixed this error.

Advertisement

Answer

The error message is very clear “Could not authenticate”. I would say you are correctly using the PHPMailer class, but just not filling in the correct gmail account details.

I suppose that in your question the fields username and password look like

JavaScript

just because you, obviously, don’t want to share them, I would suggest to present them like this in the question

JavaScript

So if you are using the correct username and password there are other two things to check

  1. Maybe your setting “Access for less secure apps” is turned off. After you login from the web you can turn it on from this page https://www.google.com/settings/u/0/security/lesssecureapps

  2. If that is On, it might be possible you have 2-Step Verification enabled in your gmail account. If this is the case, you need to create an App specific password.

Follow this link for a step by step guide on how to do it http://email.about.com/od/gmailtips/fl/How-to-Get-a-Password-to-Access-Gmail-By-POP-or-IMAP.htm

User contributions licensed under: CC BY-SA
8 People found this is helpful
Advertisement