WordPress is great, and PHP is great as well. But the PHPMail function in WordPress can lead the system-generated emails to user’s spam folder or even worse be blocked by mail services provider.
So I started to use some SMTP plugins to set up the mail server to send out emails through SMTP protocol. The best SMTP services choice for me is GMAIL besides the hosting company I have now, since the mail server from Google has the best setting which can avoid the spam/junk filtering.
1, Gmail Settings
First, let us find out the basic setting for Google SMTP service as the following:
- Gmail SMTP server address: smtp.gmail.com
- Gmail SMTP username: Your full Gmail address (e.g. firstname.lastname@example.org)
- Gmail SMTP password: Your Gmail password
- Gmail SMTP port (TLS): 587
- Gmail SMTP port (SSL): 465
- Gmail SMTP TLS/SSL required: yes
Second, you choose whichever SMTP plugins in WordPress you like. I used WP-SMTP, and someone recommended Easy WP SMTP plugin. Finally, I settled down with a Chinese plugin named WPJAM which has a lot of other features too.
No matter which plugin you chose, the setup process in WordPress should be very straightforward. But the difficult part is the Gmail authentication errors you encountered.
When you set this up, and tested you might have an error indicated the Authentication failed. And since all coding was working before, nobody couldn’t figure out why.
2, step 1-enable Less Secure Access
Until when you opened the Gmail inbox and read a notification from Google saying that they had blocked a sign-in to your gmail account. You knew how to resolve this issue by taking the first step: Authorize the unsafe access to your Gmail account.
Email notification from Google about the blocked sign-in attempt. (Picture credit goes to WP SiteCare)
It turns out that in order for Google to authorize a third party server to access your account via SMTP now, you have to enable “Less Secure Apps” on your gmail account. If you do choose to enable less secure app access, you can do that on this page in your gmail account. There’s a screenshot below of where you’ll find the setting. Please don’t enable this access unless you fully understand what’s going on, and what the possible ramifications are.
3, Step 2 – Disable login captcha
After you have done the step 1, you might have been lucky to get the email through in WordPress. If you were not just like I was, you should continue to move on with the next step.
Since Google keeps changing its security methods, you had to go to the page below after you turned on “Allow Less Secure Apps”
Hope it helps someone.