How to send email using SMTP & Gmail in WordPress

Gmail logo_2020

When setting up WordPress websites, there’s a fairly common issue which can sometimes be encountered, relating to the delivery of emails. The problem is that emails sent by the website fail to arrive in your inbox or perhaps keep landing in spam, and you may be left scratching your head as to why they’ve gone missing.

The most common examples of the emails that could be affected are those that should be sent to you when someone sends an enquiry via forms on your website, and the verification email which should be sent when there’s a change of admin ownership for the website in Settings > General.

Initial troubleshooting

The first things to check in these cases should be your SPF (Sender Policy Framework) and DKIM (Domain Keys Identified Mail) records within the DNS for your domain, as these control which servers are permitted to send emails on behalf of your domain – the system is designed to prevent people sending fake email pretending to be you. There are Google help pages here for SPF and here for DKIM.

You may still find that the email delivery issue persists even after checking that your SPF and DKIM are correct. In these cases, and particularly if you’re using Google Workspace for your domain’s email hosting, the root cause is probably something else.

The next thing to check should be your Email Routing configuration in cPanel – if you’re using a 3rd party service like Google Workspace, you should select the Remote Mail Exchanger option.

If that still doesn’t solve it and you’re using Google Workspace to send normal email over your domain, the next step is to set up something called SMTP (Simple Mail Transfer Protocol). This makes everything much more robust and reliable and is pretty much guaranteed to solve the problem. It takes a little bit of work to set up – but don’t worry, as always we can take care of all the technical stuff so you don’t have to.

Overview of our recommended process

In the following steps we’ll show you exactly how to set up and configure SMTP and solve your email deliverability problem, using an excellent free plugin for WordPress called Post SMTP Mailer/Email Log. You can either follow these steps yourself, or alternatively if you’re an erjjio client just let us know if you’d like any help and we’ll be able to do almost all of it for you ourselves. All we’ll need is for you to set up a free account in the Google Cloud console and then invite us as a collaborator – see later steps.

There are several other SMTP plugins for WordPress out there to choose from, however we feel this one is currently the best on offer, because:

  • It has an integrated email log, which shows you which emails were sent successfully and which failed;
  • The email log works as soon as the plugin is installed, even if SMTP hasn’t been configured yet;
  • It has a webhook integration for Slack, so you (or we) can get instant alerts if an email fails to send.

Set up the Post SMTP Mailer/Email Log plugin

1. Install and activate the Post SMTP Mailer/Email Log plugin via Plugins > Add New. It’s also available for download in the WordPress repository here. Once activated, you will see a message asking for your permission for the plugin’s developers to track non-sensitive diagnostic data about the plugin’s usage on your website. Our view is that it’s safe to opt in to this, but feel free to opt out by clicking Skip if you prefer. If you opt in, you’ll receive an automated email asking you to confirm your email address, with a button to click on.

2. Go to the Post SMTP tab in your WordPress dashboard and click the orange Start the Wizard button.

3. Enter your company or website name in the Name field, and your (Google Workspace) email address which will be used as your admin email for the website, in the Email Address field. For example, our own business email runs through Google Workspace and we use the below – you would replace these with your own details.

4. Click the Next button.

5. The wizard should automatically set as the Outgoing Mail Server Hostname.

6. Click the Next button.

7. Select the Gmail API option, then click the Next button.

8. At this point you’ll arrive on the Authentication tab of the wizard, and in order to proceed with the configuration, we need to set up a separate, free tool called the Google Cloud console.

Set up the Google Cloud console

9. Open the Google Cloud console here.

10. Make sure you’re signed in using the correct Google account, by clicking the profile icon in the top-right of the window. This should be the same Google account that you’re configuring for the website – make sure you’re not accidentally signed in with your personal Gmail account instead, for example – and switch to your business account instead if so.

11. If this is the first time you’ve used the console for your Google account, select your country of residence, tick the box to agree to the Terms of Service, select your preference for the email opt-in then click the AGREE AND CONTINUE button.

12. Click the blue ACTIVATE button (see screenshot above) at the top of the page to claim your free billing credit. Even once this credit runs out, Google continues to offer free usage within an ongoing monthly quota, which is more than enough for most small business websites.

13. Click the link to create a NEW PROJECT via the toolbar at the top.

14. Name the project “SMTP for [your website name]” then click CREATE.

15. Click the SELECT PROJECT link for your new project, in the notification that should pop-up in the upper right of the screen (or you can select it from the list of recent projects via the drop-down next to the Google Cloud logo in the upper-left).

16. Click the hamburger menu in the upper-left, then hover over APIs & Services and click Library.

17. Search for “gmail” then click the Gmail API result.

18. Click the blue ENABLE button.

19. At this stage, you can either continue with the following steps yourself, or if you prefer you can add us as a collaborator and we’ll do most of it for you (we’ll just need you to hop in at the end, to send a test email).

If you’d like to configure everything yourself, jump to step 25 below.

Add the erjjio team as a collaborator (optional)

20. Click the menu in the top-left of the window, then select IAM & admin > IAM.

21. Click ADD on the toolbar then in the “New principles” field enter and set the role to Basic > Editor then click SAVE.

22. Click the blue SAVE button (visible once the role has been selected above).

23. Check that we have been successfully added as an Editor, as shown below.

24. Please send us a brief email or message in your Basecamp project at this stage, to let us know that you’ve added us – as Google doesn’t send us an automatic notification about it.

If you’ve added our team as a collaborator in this way, we’ll do the next part for you. We’ll just need you to jump in right at the end, at step 47, in order to send a test email – as you’ll need to login to your Google account using your private password, rather than you needing to share this sensitive information with us. We’ll let you know once we’re ready for you to do that last bit.

If you’d prefer to complete the rest of the steps yourself, continue onto step 25 below.

Configure the Gmail API credentials

25. Click the menu in the top-left of the window again, select APIs & Services > Credentials

26. Click the button to + CREATE CREDENTIALS then select the OAuth client ID option.

27. Click the blue CONFIGURE CONSENT SCREEN button.

28. On the next page, select the External option then click CREATE.

29. Enter “Post SMTP” as the App name and select your contact email address from the dropdown in the User support email field.

30. Enter the URLs for your website home page, privacy policy and terms (if applicable).

31. In the Authorised domains section, click + ADD DOMAIN then enter your website’s domain (not the URL – i.e. without https:// at the start).

32. In the Developer contact information section, enter



35. On the next two tabs for Scopes and Test users, simply click the SAVE AND CONTINUE button for both of them – it isn’t necessary to enter information here.

36. Click the OAuth consent screen tab in the sidebar on the left, then click the PUBLISH APP button, then CONFIRM.

Link the Post SMTP plugin to the Gmail API

37. Click the the Credentials tab in the sidebar on the left, then the + CREATE CREDENTIALS button at the top, then select the OAuth client ID option (this is a repeat of step 26 above, now that the “OAuth consent screen” has been configured).

38. On the next page, select Web application from the Application type list.

39. Enter a Name of your choice – we suggest “WordPress“.

40. Go back to step 8 on this help page above, and copy/paste the Authorised JavaScript origins and Authorised redirect URI values provided by the Post SMTP wizard (in your WordPress dashboard) into the matching URI fields in Google Console, shown below.

41. Click the blue CREATE button.

42. You will then be shown a unique Client ID and Client Secret – similarly, copy/paste these values back into the matching fields in the Post SMTP wizard in your WordPress dashboard (also shown in step 8 above, and in the screenshot for step 43 below).

43. Click OK in the “OAuth client created” window above, and click Next in the Post SMTP wizard in your WordPress dashboard.

Complete the Post SMTP wizard

44. You can optionally set up notifications so you’ll get alerted if your SMTP connection ever breaks. There are options for Email, Slack and a Chrome extension – they are all free and simple to set up, if you’d like to.

45. Click Next.

46. Click Finish.

47. Click the Post SMTP plugin tab in the sidebar of the WordPress admin dashboard, then click Grant permission with Google.

48. Select the same Google email address that you specified in the earlier steps.

49. Review the message and click Allow.

50. Back on the Post SMTP Setup page, you should now see a message confirming that Postman is successfully configured – to double-check this, click the link to Send a Test Email.

51. Specify a recipient of your choice, then click Next.

52. All being well, you should then see a confirmation that the test was a success, and an email should arrive in the recipient mailbox you specified.

That’s it – all done!

If you’re an erjjio client and you get stuck with anything, please get in touch 🙂

Reader Interactions

Leave a Reply

Your email address will not be published. Required fields are marked *