Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Make PHPmailer a "more secure app" for Gmail

What security can we implement in PHPmailer to make it a more secure app for Gmail? https://support.google.com/accounts/answer/6010255 I am using PHPmailer to send emails via Gmail. PS: I don't want to enable "access for less secure apps" here: https://www.google.com/settings/security/lesssecureapps, I want to make the app more secure.

like image 272
mpower2k Avatar asked Jan 24 '15 11:01

mpower2k


People also ask

How do I change less secure apps on Gmail?

Go to the Less secure app access section of your Google Account. You might need to sign in. Turn Allow less secure apps off.

How do I enable secure apps in Gmail?

To enable the option in Gmail: Log into your account at Gmail.com, then open another tab and go the Less Secure Apps Setting, and select “Turn on”.

Is PHPMailer secure?

PHPMailer doesn't create/use any SQL itself, nor does it have anything to do with javascript, so it's secure on those fronts.


1 Answers

Gmail has started imposing a new authentication mechanism that substitutes SMTP athentication for OAuth2-based authorisation. The docs on their changes can be found here.

This doens't really improve security much because ultimately you still need to submit your username and password over SSL at some point (the very mechanism that google deems insecure) to authenticate to get an OAuth token, which is exactly as secure as existing SMTP auth systems.

As yet, PHPMailer does not support this new mechanism - PRs welcome! You will need an OAuth2 class, such as this one, and perhaps make use of this code example.

In the mean time, you do have to "enable access for less secure apps", and you should set SMTPSecure = 'tls' and Port = 587 and use normal auth to connect using PHPMailer.

Update

PHPMailer supports Gmail's XOAUTH2 authentication as of version 5.2.11. See this guide. It's being expanded in version 6.0 to support other services too.

like image 154
Synchro Avatar answered Oct 13 '22 23:10

Synchro