How to send email using SMTP and Office 365 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 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. 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 a 3rd party such as G Suite or Office 365 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 such as G Suite or Office 365, you should select the Remote Mail Exchanger option.

If that still doesn’t solve it and you’re using Office 365 to send business 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 – if you’re an erjjio client we can take care of most of 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 SMTP plugin for WordPress called Post SMTP Mailer/Email Log.

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.

The main downside when using it with Office 365 business email however, is that it requires a paid extension for the main SMTP plugin – whereas it’s free to use with Google Workspace for example. Despite this drawback, we still feel that the above benefits outweigh the cost. If these features/benefits aren’t very important to you however, in our opinion the next best and free alternative is FluentSMTP, which you could try instead.

You’ll need to purchase the licence for the Office 365 extension first, before proceeding with the rest of the steps below.

Set up the Post SMTP Mailer/Email Log plugin

1. Install and activate the main Post SMTP Mailer/Email Log plugin – it’s available for download in the WordPress repository here or via the Plugins > Add Plugins section in your WordPress dashboard.

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

3. Install and activate the paid Office 365 extension plugin you have purchased too, and enter your purchased licence key when prompted. This can also be entered/updated via the Change License link.

4. Once both plugins are active, go to the Post SMTP tab in your WordPress dashboard and click the orange Start the Wizard button.

5. Enter your company or website name in the Name field, and your (Office 365) email address which will be used as your admin email for the website, in the Email Address field.

6. Then click the orange Next button.

7. The wizard should automatically set smtp.office365.com as the Outgoing Mail Server Hostname. If it shows relay-hosting.secureserver.net instead, change it manually to smtp.office365.com – and ignore the message about GoDaddy, unless you purchased your Office 365 licence via GoDaddy, in which case it would be best to follow their advice on updating the SPF record (we can help you with this if needed).

8. Click the Next button.

9. Select the Office365 API option (note: you will only see this within the available options to select from once you’ve installed the paid Office 365 extension for the core SMTP plugin, as described in the overview section earlier in this article).

10. Click the Next button.

11. At this point, you’ll need to set up an App ID, App Secret and Redirect URI in your Office 365 / Azure account in order to proceed. Follow the instructions to create these via the Azure portal link which the plugin provides, and watch their short YouTube video which walks through an example of how to do this too.

  • The App ID and App Secret will get produced in your Azure account (as per the Azure link and YouTube video above), and you should then copy/paste them into the respective fields of the SMTP wizard as shown below.
  • Whereas the opposite applies for the Redirect URI – the SMTP plugin should generate this for you, and you should then copy/paste it into your Azure portal. It’s also generally best to set up two of these Redirect URIs in your Azure account – one for the development website, and another for the live website:
    • The development website we build for you during a project will have a URI in the format: https://dev.erjjiostudios.com/[your project name]/wp-admin
    • The live website will be in the format: https://[your own domain]/wp-admin

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

13. Click Next.

14. Click Finish.

15. Back in your Post SMTP dashboard – you should now see a message confirming that “Postman is configured” and also “Office 365 is configured”. To double-check this, click the link to Send a Test Email.

16. Specify a recipient email address of your choice, then click Next.

17. 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. You can click Finish the return to the SMTP plugin dashboard.

That’s it – all done!

If you’re an erjjio client and you get stuck with anything in this process, 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

Comments

  1. Abdulrehman Altaf says

    thanks for the info and good article.
    update, before “Begin by setting up the Post SMTP plugin”
    make sure to enable SMTP from office on specific account/tenant level, other wise its not going to work.

    Use the Microsoft 365 admin center to enable or disable SMTP AUTH on specific mailboxes
    1: Open the Microsoft 365 admin center and go to Users > Active users.
    2: Select the user, and in the flyout that appears, click Mail.
    3: In the Email apps section, click Manage email apps.
    4: Verify the Authenticated SMTP setting: unchecked = disabled, checked = enabled.
    5: When you’re finished, click Save changes.

Leave a Reply

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