Azure Mailjet SMTP

Enable email in Umbraco or Sitecore with Azure Mailjet SMTP

Seann Hicks

Seann Hicks

Wednesday, October 9, 2019

Azure Mailjet SMTP email Service in Azure

Azure Mailjet SMTP Secure Email Graphic

So I thought SendGrid was the only free email option in Azure.  However, there is another email service that is almost as easy to set up, Mailjet.

To get started with Mailjet, search it by name in the Azure Marketplace and add it to your resource group.  There are several plans to choose from, ranging from the free plan that allows 6000 email (monthly), to 900K emails.  Mailjet has additional email campaign features like mail tracking, the responsive marketing tool, dedicated IP, and contact management.  The Premium accounts include segmentation, A/X testing and campaign comparison.

Azure Marketplace MailJet Service

Mailjet seems to emphasize security.  In fact, from the Azure Portal, my API Key is in 'Quarantine' which means there is a per hour send limit (I believe 1000 is the limit on the free plan).  Validation requires the addition of some DNS records to ensure that you in fact own the email domains you are using.  An email SPF and DKIM record is required to fully validate your account.

To verify your email domain, you'll need access to your DNS record management.  Go to Account Settings->Senders & Domains->Setup SPF/DKIM Authentication to accress the screen that provides and verifies the details required for your DNS record set.

MailJet SPF and DKIM settings

It will take at least 30 minutes to a couple of hours or possibly longer for the DNS records to be propagated.  The verification screen can be closed and checked later if needed, the values it displays will not be changed, so it is safe to close the window.  You may want to wait a day before coming back to this screen to ensure the validation succeeded.

Initial Setup

From the Azure portal you'll be asked to supply a Mailjet contact, including an email address. This information is transferred over to Mailjet and the email account will have to be verified by Mailjet.

MailJet Contact Information 

The odd thing about setting up accounts like this from Azure is that a proper Mailjet account that you can use to login from the Mailjet login will not be created.  What I ended up doing was doing a password reset from the Mailjet login screen using the email address I used my Mailjet contact record.

The Mailjet password reset works like any other password reset, you get a link emailed to your account and clicking that link opens a screen allowing you to choose a new password.  Once I had my account sorted out I could log into my Mailjet account using the web front end instead of using the Azure "Manage" button to access the account.

Umbraco Configuration

It is highly recommended, well, mandatory really, that you use TLS to connect to Mailjet. To setup an Umbraco or Sitecore instance with Mailjet is simple. Go to the Mailjet Properties in Azure to obtain these values. The settings work as follows:

 

This is an example of my web.config settings for Umbraco.

Verify your setup

You can test your email configuration by setting up an Umbraco Workflow and requesting a content review. This will send an email to the reviewer account. If you don't have workflow setup, you can also use the password reset feature to test the email configuration.

You can also use the Umbraco Health Check from the "Develop" tools in the back office. Navigate to the "Develop" tools gear and pick the "Health Check" tab. Click "check group", if the SMTP server is not valid, or cannot be connected to with the account credentials, an error is displayed.

Umbraco SMTP Health Check showing valid settings

Azure SMTP MailJet API

If you need to send emails from you site, or collect contacts and manage campaigns, you'll want to use the Mailjet API.  There is a convenient library that can be installed via NuGet.  There is ample documentation on the Mailjet site with examples for this library.  In a future post I will go through my implementation of an email contact subscribe and unsubscribe implementation in Umbraco.

Azure MailJet SMTP C# API NuGet package

Best of luck with you Azure Mailjet implementation!

Sources Cited

MailJet Developer Reference

MailJet Developer Resource

Photo by Tim Evans on Unsplash

Sign-up to receive the weekly post in your inbox. I don't share email addresses, unsubscribe at any time.

Email Address