November 7, 2019
4 min Read
November 7, 2019
4 min Read
Not everyone knows that they can take advantage of free Google SMTP server to send emails. It can be the ultimate solution for those, who can’t use SMTP server provided by their ISP or hosting as well as those, who experience various email deliverability issues. In this tutorial, you will learn how to use free Google SMTP server. You will also find detailed instructions about how to use it in order to send emails via PHP mailer and WordPress plugin.
Although, most hosting (for example Hostinger) and ISP offer SMTP support, there are quite a few benefits of using external SMTP service:
Google limits outgoing emails to 100 per day. If the limit is reached, you won’t be able to send emails for the next 24 hours until it resets. More information about Google email limits can be found here.
First of all, in order to use free SMTP server from Google, you need to allow access for less secure apps. Google started to block apps and devices that, according to them, do not use modern security standards. However, access for less secure apps can be easily turned on here.
IMPORTANT: If you use 2 factor authentication to access your Google account, access for less secure apps cannot be enabled. In this case, you will have to sign in using App password.
You can find Google SMTP details below:
If you want to take advantage of IMAP protocol and store all outgoing emails in your Gmail Sent folder, follow these steps:
In this step, you will learn how to use free SMTP from Google in order to send emails using PHP mailer and WordPress plugin. Knowing how to send emails via PHP is useful whenver you are learning to code or just want to build a simple contact form for your website.
There are many PHP mail scripts available. In the example bellow, we will be using PHPMailer:
PHPMailer already has a sample configuration file named gmail.phps to use with Google SMTP servers. It’s located in PHPMailer-master/examples folder.
In order for this script to work with Google SMTP server, you will have to edit it and change settings like username, password and email recipient address. You also need to rename this file from gmail.phps to gmail.php so that it would be accessible via browser. You can use the same file manager or FTP client to rename and edit the file with your details.
Once you are done editing, simply open the script with your browser. If you have uploaded PHPMailer-master folder to public_html folder, the file should be accessible via http://yourdomain.com/PHPMailer-master/examples. If everything is configured correctly, you should see a success message indicating that the email message has been sent successfully.
The easiest way to use external SMTP on WordPress is to use WP Mail SMTP plugin.
Firstly access your WordPress admin dashboard and go to Plugins > Add New section. Install and activate WP Mail SMTP plugin.
Now access WP Mail SMTP settings page by going to Plugins -> Installed Plugins and clicking Settings.
You will have to fill in all the required details of your SMTP server.
To save the changes you have made click Save Changes button at the bottom. To make sure your settings are working correctly you can test it by sending a test email to your personal mail account. Enter your email address and click Send Test.
If you receive your sent email it means that mail sending is working correctly. However, if you get any error messages, double check email settings or contact hosting support team for assistance.
Upon finishing this tutorial, you have learned how to configure your Google account and use free Google SMTP server. You’ve also learned how to send emails via PHPMailer.
October 05, 2017
It has an error, says, "Message body empty"
October 14, 2017
When trying to send an email with my google account, I get this error message— CANNOT SEND MAIL the connection to the outgoing server “smtp.gmail.com” has failed. Additional outgoing mail servers can be configured for mail accounts in settings>
Replied on November 30, 2017
Have you done this: "Access for less secure apps can be easily turned on here."
February 26, 2018
The "SMTP Port Number" mentioned in Step I is wrong, it is '587', I followed the instructions literally and was getting Stack Trace error because of it, so i rechecked the settings changed the port number to 587 and then i was able to get the mails sent. Nice tutorial though Thanks!
Replied on February 27, 2018
Hey Kadahsh, Thanks for pointing this out. Tutorial has been updated with a correct port number!
June 10, 2019
Worked like charm! Thanks a lot for the detailed steps.