If you are facing any issues in sending an email in WordPress, then this guide is for you. Here, we discuss how to configure your WordPress so it can send emails properly.
The email configuration that may work for you will depend upon the hosting provider. So, we take two different cases either when you use shared hosting of GoDaddy, Hostgator, etc. where you have access to cPanel, or when you use VPS (Virtual Private Server) like Digital Ocean, Linode, or Vultr, etc.
Here, we use the plugin WP Mail SMTP by WPForms to configure the sending of an email. This plugin fixes the delivery of an email by reconfiguring the WordPress to make use of the correct SMTP provider when sending the emails.
More specifically, this plugin reconfigures the wp_mail() function of WordPress to make use of the proper SMTP host credentials. By default, WordPress makes use of the PHP mail() function for sending emails which may not work in some cases.
In VPS hosting, you may use Gmail SMTP, Pepipost SMTP, SendGrid SMTP, etc settings for sending emails.
But, in the case of shared hosting providers, generally, they restrict you from using SMTP providers like Gmail.
First of all, install and activate the “WP Mail SMTP by WPForms” plugin, then proceed to the next step depending upon the type of hosting you use.
Email Configuration in cPanel Powered Shared Hosting
This should also work in managed WordPress hosting as offered by hosting providers in this category.
Here, you can set the “Mailer” to “Default (none)” and then click on “Save Settings”. This will simply reconfigure the wp_mail() function of WordPress.
Then, you can test sending an email in the “Email Test” tab.
If this does not work for you, then you can try using “Other SMTP” and input the SMTP details as provided by your hosting provider.
Generally, in shared hosting with cPanel, you get these SMTP details in the “Email Accounts” section of your cPanel.
Email Configuration in VPS (Virtual Private Server)
In VPS like Digital Ocean, Linode, etc., you can use SMTP providers like Gmail. Also, the hosting provider of VPS does not block Gmail SMTP in most cases.
Here, we are going to take Gmail as an example. Select “Other SMTP” in the “WP Mail SMTP” plugin and input the Gmail SMTP details. These are as follows:
- SMTP Host: smtp.gmail.com
- Encryption: TLS or SSL
- Port: 587 or 465
- SMTP Username: Your Gmail account username or email address
- SMTP Password: Your Gmail account password
Lastly, you will also need to allow less secure apps. This is specifically the case in Gmail. So, turn on “Allow less secure apps”.
After, allowing less secure apps, you can test sending the email.
Similarly, you can configure any other SMTP provider besides Gmail.
There are many hosting providers that offer SMTP services. It’s not easy to choose between them since each hosting provider has its pros and cons. Now, to find the best email hosting provider with SMTP, you can read this comprehensive guide on email hosting.