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.
Table of Contents
Benefits of Using External SMTP Service
Although, most hosting (for example Hostinger) and ISP offer SMTP support, there are quite a few benefits of using external SMTP service:
- They can ensure better email deliverability.
- You won’t have to setup your own server (if you use VPS).
- Their servers are less likely to be blacklisted, which means, your email is less likely to be labelled as SPAM.
Free Google SMTP Sending Limits
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.
Before you begin this guide, you’ll need the following:
- Gmail or G Suite account
- Access to your hosting control panel
Step 1 – Getting Google SMTP Server Settings
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:
- SMTP Server : smtp.gmail.com
- SMTP Username: Your full Gmail username (email address), for example firstname.lastname@example.org
- SMTP Password: Your Gmail password.
- SMTP Port: 587
- TLS/SSL: Required.
If you want to take advantage of IMAP protocol and store all outgoing emails in your Gmail Sent folder, follow these steps:
- Login to your Gmail account and access Settings section.
- Jump to Forwarding and POP/IMAP tab and enable IMAP.
- Press Save Changes button at the bottom of the page once you are done.
Step 2 – Using Google SMTP
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.
Option 2.1 – Using PHPMailer
There are many PHP mail scripts available. In the example bellow, we will be using PHPMailer:
- Open PHPMailer repository on GitHub and download the script by pressing Clone or download -> Download ZIP button. Save it to your computer.
- Upload the archive to your hosting account. You can use FTP client or file manager provided by your hosting for this. If you’re not sure how to upload files to your hosting account, see this tutorial.
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.
Option 2.2 – Using WP Mail SMTP Plugin
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.
- SMTP Host – Enter smtp.gmail.com.
- SMTP Port – Default Gmail SMTP server port is 465 for SSL and 587 for TSL.
- Encryption – It’s always recommended to use encryption. Choose it according to the port you have specified.
- Authentication – Select Yes as SMTP authentication is required.
- Username – your Gmail address.
- Password – your Gmail password.
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.