How to Use SMTP to Send Email from WordPress

Posted on April 6, 2016 by in Tips & Tricks | 22 comments

How to Use SMTP to Send Email from WordPress

SMTP can be a lot more reliable than the typical mail function in WordPress. There may come a time where the standard PHP mail function in WordPress stops working properly, causing you to run into problems with getting emails to send and receive emails correctly. You’ll want to connect your site to an SMTP server if this is the case.

You need to use your email provider’s server, which means retrieving the SMTP settings in most cases. We’ll go over how to set up these types of settings using the Easy WP SMTP and WP Mail SMTP plugins in the first section. Instructions on how to connect your site to Gmail’s servers are in the second section.

So let’s get right to it!

How to Use SMTP with Most Email Providers

easy-wp-smtp-plugin

These instructions will work with most email providers, including the branded emails you created with your host inside of cPanel. These instructions used to work for Gmail SMTP integration with WordPress, but you’re likely to run to issues these days due to the security changes Google has made in regards to SMTP. Continue to the next section to find more reliable instructions on how to set up SMTP with Gmail inside of WordPress.

Install and activate the Easy WP SMTP plugin in WordPress, and open its settings to get started. You can also use the WP Mail SMTP plugin.

How to Configure These Plugins

from-email-address-name

Enter the email address and name you’d like your emails to be sent from in the From Email Address and From Name fields. Set the SMTP Authentication setting to Yes if the plugin hasn’t done that for you already. Enter the email address and password you use to log into your email account in the SMTP Username and SMTP Password fields. Click Save Changes

The SMTP Host, Type of Encryption and SMTP Port settings are dependent on the email host you use.

Finding Your SMTP Settings in cPanel

If you’re using your host to create branded emails, open cPanel, scroll down to the Email section, and select Email Accounts or Email Manager.

If there’s a dropdown menu for each individual email account, open the dropdown menu for the email you wish to use, and select Configure Email Client. If you’re using a different version of cPanel, click Email Configuration in the menu on the right-hand side of the Email Manager section, and select the email account you’d like to use.

cpanel-smtp-settings

Use the Outgoing Mail Server and the Supported Port underneath it in the settings in Easy WP SMTP. If you’re using the SSL settings, copy the Outgoing Mail Server URL, and paste it in the Host field in Easy WP SMTP. Select SSL as your Type of Encryption, and enter the Supported Port number in the Port field.

If you’re using the non-SSL settings, follow the same steps, but set the Type of Encryption to TLS.

test-email

Click Save Changes once you’re done, and send a test email in the Testing and Debugging Settings section. You can also run a test by leaving a random comment on one of your blog posts if you have the Email Me Whenever Anyone Posts a Comment setting selected in the Discussion settings.

Asking Your Email Provider for Help

Some email providers display their SMTP settings in the support sections of their websites while others simply don’t. If you’re having trouble finding the specific settings your email provider uses, you may need to contact them directly.

Make sure you get all of this information:

  • The server
  • The port number
  • Type of Encryption Needed – None, SSL or TLS
  • Authentication Needed – Yes or No

Make sure you also tell them why you need the information and who’s hosting your website. Some web hosts block certain servers, which causes errors when sending and receiving emails.

If nothing seems to be working and you’ve only tried one of the plugins mentioned above, uninstall it, and try the other plugin.

How to Use SMTP with Gmail

Gmail is one of the most popular email providers on the web, meaning your emails are less likely to be marked as spam if you send them using Gmail’s servers. You can create your own branded emails with Google Apps for Work. These instructions will work for both branded email addresses and regular @gmail.com email addresses.

Using the Correct Plugin

postman-smtp-plugin

Using Gmail’s servers to send email from WordPress used to be as simple as configuring a few settings in the WP Mail SMTP and Easy WP SMTP plugins, but this is no longer the case. Google has made a few security changes that make these plugins more difficult to configure, so your best bet is to use the Postman SMTP Mailer/Email Log plugin instead.

Once you install and activate the plugin, open its settings by selecting it from the Settings menu in the WordPress admin area. Click the Show All Settings link under the large Start the Wizard button.

Select Gmail API for Type under the Transport settings. Your Authorized JavaScript Origins and Authorized Redirect URL fields are already filled in. You’ll need these details later.

You’re required to create a Client ID inside of the Google Developers Console in order to fill in the Client ID and Client Secret fields.

Creating a Client ID with Google Developers Console

Make sure you’re signed into the Gmail account you’d like to use to send emails from WordPress, then open the Google Developers Console.

register-gmail-api

Select the Google Account you’d like to use to send your emails. You’ll be asked whether or not you’d like to register your application for the Gmail API in Google Developers Console. Select Yes, and click Agree and Continue.

Click Go to Credentials once the API is enabled.

create-client-id

Once you’re on the Credentials screen, find the text underneath the Find Out What Credentials You Need section that says, If you wish you can skip this step and create an…” Select Client ID.

Click the Configure Consent Screen button. You’ll be taken to the OAuth Consent Screen tab. Your email address should already be selected for you. Select it if it isn’t. Type “Postman SMTP” in the Product Name Shown to Users field. Click Save at the bottom of the page.

Now you can create a Client ID. Select Web Application as your Application Type. Now you’ll need the information that was filled in for you inside of the Settings screen of the Postman SMTP plugin.

Copy your URL from the Authorized JavaScript Origins field on the Settings page of the Postman SMTP plugin, and paste it in the Authorized JavaScript Origins field in the Google Developers Console. Do the same with the Authorized Redirect URL fields, and click Create at the bottom of the page in Google Developers Console.

You now have a Client ID and Client Secret.

Configuring the Postman SMTP Plugin

oauth-client

A pop-up box that contains your OAuth Client information should appear after you create your Client ID. Copy the Client ID, and paste it in the Client ID field on the Postman SMTP settings page. Copy the Client Secret from the OAuth Client, and paste it in the Client Secret field in Postman SMTP.

grant-permission-with-google

Click the Save Changes button on the Postman SMTP Settings page. You should see a notice at the top of the page that states you need permission from Google. Click the Grant Permission with Google link.

You’ll be taken to a page that says “Postman SMTP would like to view and manage your mail.” Click Allow.

Now Postman SMTP is ready to send emails for you, but there’s one final step. Click the Message tab on the Settings page. Enter the email address and name you’d like your emails to appear to be sent from in their respective fields. Click Save Changes at the bottom of the page.

Sending a Test Email

Click Send a Test Email under the Actions heading. Enter a recipient, and click Next. The message should send without failure. Go over these steps, and make sure you didn’t miss anything if the message fails to send. Make sure you granted permission with Google.

You can also leave a random comment on one of your blog posts to test if things are working correctly, but this depends on whether or not you’ve asked WordPress to send you an email whenever someone leaves a comment in the Discussion settings.

Final Thoughts

SMTP servers can cut down on the amount of issues you encounter with sending and receiving emails through your WordPress site, but they can also be a pain to set up. If you’re having trouble figuring our your email provider’s settings, don’t hesitate to contact them directly for help.

If you have trouble using your email provider’s settings, consider setting up a Google Apps for Work Gmail account or a standard Gmail account specifically for this function, and use the Postman SMTP plugin to set everything up. SMTP settings aren’t required when you go with this method.

Do you have any tips on how you set up SMTP on your WordPress site? Share them in the comments below.

Article thumbnail image by venimo  / shutterstock.com 

22 Comments

  1. Great Article!

  2. Nice plugin, but how it can be useful for normal bloggers ?

    • Nathan B. Weller

      Hi Yogiraj, this is useful to normal bloggers in that it is a more reliable way to send and receive emails via your WordPress website. Which can include contact form submissions, comment notifications, and new post emails to your readers.

  3. Been looking for an in depth article like this for a while! To many of my contact form submissions go to waste – thanks elegant themes !

  4. Can this be used to send 2000 emails at once? That’s what I need is to send mass emails from either wordpress or my host at one time. That’s how many members I have. Can this be done?

    • @BobM – Most servers have an email limit around 200-300 emails per hour. Gmail I think is 500 per hour. Your better off using a dedicated email service if you need to send that many emails all at the same time. There are settings to allow your server to send so many emails per hour within their specified limits. So you send your email to 2000 and the server sends 300 per hour until its completed the job.

  5. FYI, I’m using Webriti SMTP Mail Plugin since 2 years with Gmail. Working like a charm, extremely simple to configure.

  6. SendGrid and Mailgun both work really well for transactional email. With SendGrid being really easy to setup.

  7. I’ve never had a problem sending emails through wordpress so far. Is SMTP considered a “best practice”? Should I make this a default setup when creating customer websites that use standard contact forms?

    I try to limit the number of plugins I use on my sites but if this is the best way to send email I will start adding a SMTP plugin with my customer websites.

    Any thoughts on this?

    Thanks!

  8. The problem is if someine sends a mail through the site contact doen you reply because you Will send yourself a mail. The mailadres of the person who contacts you is lost

  9. I got a suggestion by the Admin to switch to SMTP method for security reasons, the plugin I used is WP Mail SMTP

    I believe that’s less worrying in terms of security, in addition with the appropriate anti-spam plugins.

  10. I recently tried to figure out how to configure an open source email server, so that we didn’t have to pay to send out newsletters to our users. I thought it should be easy to setup an RSS-populated email newsletter, but it was so complex though! Too complex for me, as it turned out.

    If you could post info how to best do that, within wordpress or not, it would be very much appreciated!

  11. Great and detailed article. Thank you for sharing +1 from me.

  12. Hi,

    I just want to recommend my free plugin also, which is created especially for WordPress Multisite networks to configure the SMTP for all sites in a network. So if somebody is managing a Multisite, this plugin will make it much easier to configure the SMTP settings.

    Surbma – SMTP: https://wordpress.org/plugins/surbma-smtp/

    Thank you!

  13. tnk a lot so good:)

  14. I’ve used this plugin in the past for a client who could get mail() setup. Was impressed.

  15. What is SMTP?

    • Hi Paul, SMTP is Simple Mail Transfer Protocol

      It is one of the protocol used for sending mails over the Internet.

  16. I use Mandrill that is now a part of Mailchimp. It works great for me, and they have their own plugin.

  17. Decent article yo. SMTP is great if you don’t send out more than 500 emails a month.

    On my site, I use Amazon SES to deliver all mail. It’s affordable at like 10,000 emails for $1 and it’s 100% guaranteed to deliver into the inbox (assuming you setup / configured properly).

500,591 Customers Are Already Building Amazing Websites With Divi. Join The Most Empowered WordPress Community On The Web

We offer a 30 Day Money Back Guarantee, so joining is Risk-Free!

Sign Up Today

Pin It on Pinterest