Configuring SendGrid for WordPress on Azure

When hosting a WordPress site as an App Services site on Azure you will find email will not work. Microsoft does not provide the ability to send mails directly from the App Services site, you need to use an external relay service such as SendGrid instead

https://docs.microsoft.com/en-us/azure/virtual-network/troubleshoot-outbound-smtp-connectivity

Setting up SendGrid on Azure

Within your Azure subscription, create a new resource searching for and selecting SendGrid

As when creating any Azure resource complete the wizard defining your Resource Group and the other properties required or SendGrid. I wont go into a lot of details here on setting up SendGrid as Microsoft had a great bit of documentation already.

https://docs.microsoft.com/en-us/azure/sendgrid-dotnet-how-to-send-email

Setting up a SendGrid API Key

Within your SendGrid resource select Overview => Manage

Next on left navigation select Settings => API Keys

In the top right click Create API Key

Give your API a name and if you are only sending email using this API key you can just set the permission as Restricted Access and the only permission that is needed is Mail Send

Press Create & View at the bottom

Make sure you take a copy of the new API key as you want get to see it again in SendGrid!

WordPress

As you would imagine with WordPress there are a few ways to get mails sending via SendGrid. I personally like to use a free plugin called “Post SMTP Mailer/Email Log”

Within your WordPress admin console search for, install and active the “Post SMTP Mailer/Email Log” plugin.

Under Plugins select Settings for the newly install “Post SMTP” plugin

Click “Start the Wizard”

Set your from address as required and click Next

Set the “Outgoing Mail Server Hostname” as smtp.sendgrid.net and press Next

Select SendGrid API and click Next

Paste in your API Key created earlier in SendGrid. If you no longer have the key you will need to delete and create a new one. Click Next

On “6. Notifications” just press Next and then Finish

Finally try sending a test mail with the “Send a Test Email” wizard

Troubleshooting

You may want to add sendgrid into your domains SPF records i.e. v=spf1 include:sendgrid.net ~all

I personally had an issue with my email filtering solution blocking the emails as as spoofing attempt so I had to add a bypass rule

Leave a Comment

This site uses Akismet to reduce spam. Learn how your comment data is processed.

Pin It on Pinterest

Share

Please consider sharing.