How to send email using SMTP & Gmail in WordPress

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, 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. It’s a little bit technical – but don’t worry, we can happily check this out for you – just ask!

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 / G Suite 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 G Suite or Microsoft 365, you should select the Remote Mail Exchanger option.

If that still doesn’t solve it and you’re using G Suite 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.

Begin by setting up the Post SMTP plugin

In the following steps we’ll show you exactly how to set up and configure SMTP, to solve your email deliverability problem. You can either follow these steps yourself, or alternatively just let us know if you’d like any help and we’ll be able to do almost all of it ourselves. All we’ll need is for you to set up a free account in the Google API Console and then invite us as a collaborator – see later steps.

1. Install and activate an excellent free plugin for WordPress called Post SMTP Mailer/Email Log – it’s available for download in the WordPress repository here.

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

3. Enter the Google email address that will be used as your admin email for the website, and your company or website name in the Name field. For example, on our own erjjio studios website we use the below – you would replace these with your own details.

4. Click the Next button.

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

6. Click the Next button.

7. The wizard should automatically select the recommended Socket as SMTP – gmail.com:587 (see below). If your website is hosted with erjjio and this option isn’t available, please let us know and we will enable it for you.

8. In the Authentication section, make sure the option is set as OAuth 2.0 rather than Password. OAuth is more secure and strongly recommended.

Then click the Next button.

9. 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 API Console.

Set up the Google API Console

10. Open the Google API Console here.

11. Make sure you’re signed in using the correct Google account, by clicking the profile icon in the top-right of the window (see screenshot below). 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.

12. If this is the first time you’ve used the Google API Console for your Google account, tick the box to agree to the Terms of Service, select your country of residence, select your preference for the email opt-in (Yes / No) then click the Agree and continue button.

Whereas if you’ve used the API Console before, you can just Create a project then click Continue.

13. In both of the above scenarios, you should then see the below message confirming that the API has been enabled. Click the Go to credentials button.

14. Click the 3 dots icon in the top-right of the window, then Project settings.

15. Rename the project to “SMTP for [your website name]” then click SAVE.

16. At this stage, you can either continue with the following steps yourself, or if you prefer, you can simply add us as a collaborator and we’ll do the rest for you!

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

Add the erjjio team as a collaborator (optional)

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

18. Enter support@erjjiostudios.com in the new members field and Project > Editor for the role.

19. Click the blue SAVE button (visible once the role has been selected below).

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

21. 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, there’s nothing else for you to do – we’ll take it from here and do the rest for you!

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

Configure the project in the API Console

22. On the Credentials tab of your project, click the button to Create credentials and then select the OAuth client ID option.

23. Click the blue Configure consent screen button.

24. On the next page, enter “Post SMTP” as the Application name, then further down the page enter your website’s domain in the Authorised domains field, and the URLs for your Homepage and Privacy Policy pages – as shown in the examples below.

25. Click Save.

Link the Post SMTP plugin with the API Console

26. On the next page, select Web application as the Application type.

27. Enter a name of your choice – we suggest “Production server” or “Development server” for example.

28. Go back to step 9 on this help page above, and copy/paste the Authorised JavaScript origins and Authorised redirect URI values from the Post SMTP wizard (in your WordPress dashboard) into the matching fields below.

29. Click the Create button.

30. Similarly, you will then be shown a unique client ID and client secret – copy/paste these values into the matching fields in the Post SMTP wizard in your WordPress dashboard.

31. Click OK in the OAuth client window, and Next in the Post SMTP wizard.

Complete the Post SMTP wizard

32. You can optionally set up notifications so that 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.

33. Click Next.

34. Click Finish.

35. In your WordPress dashboard, click Post SMTP then click Grant permission with Google.

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

37. Review the message and click Allow.

38. 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.

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

40. 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 get stuck with anything or you’d like our help, please get in touch!

Join our newsletter

Interested in helpful tips, news and exclusive offers?
Join our newsletter and we'll keep you in the loop!

Reader Interactions

Leave a Reply

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