Loading...

Send emails via SMTP relay with Azure Communication Services

Send emails via SMTP relay with Azure Communication Services

We’ve come across multiple cases where customers want to send emails from applications migrated to Azure through some kind of SMTP service. Though we’ve seen customers opting for O365 for SMTP relay, this can create issues due to throttling limitations in Office Service. Also, managing mailbox and license assignment on Office 365 console is a different story; customers would want to have seamless SMTP relay service experience from single console on Azure.

In scenarios where you don’t want to modify code and just change the pointing of your SMTP server to Azure, you can now use SMTP relay built into Azure Communication Services' Email.

Azure Communication Services supports different types of notifications, and this blog post offers simple step by step instructions for how you can quickly test and then migrate from other services you’re using to native to Azure for better operational experience and support.

Create Azure Communication Services Resource


First step you’ll need to do is to create a Communication Services resource from the Azure portal. This is a parent service which has multiple notification services inside it (Chat, SMS, Email, etc). Email is one of them.

picture1.jpg

Create an Email resource

 

picture2.jpg

Add a custom domain

 

Azure Communication Services Email will provide a default domain that looks like this “GUID.azurecomm.net” and allows for a limited volume of email, so if you need more volume limits, we recommend creating a custom domain. Once you add a custom domain, the UI provides you with a TXT file which you’ll need to create in your Name server. This would take 15 minutes to verify the domain


picture3.jpgpicture4.jpg

Once the domain is verified, create SPF and DKIM records so that your email doesn’t land in junk and ownership is maintained.


picture5-1.jpg


Once all the records are created the screen would look like this, please ignore the Azure managed domain. You can only have custom domain in the account and doesn’t have to add Azure domain explicitly.

 

picture5-2.jpg

 

Attach custom domain 

 

Once the custom email domain is validated, we’ll need to attach the Email service to the Azure Communication Services resource. 

 

picture6.jpg

 

Create and assign custom RBAC Role for Authentication

 

We’ll be using 587 port to send email which is authenticated SMTP. For authentication we have Entra ID authentication. Create a service principal by going to Entra ID – App registration page. Register the app and create a client secret. Note down Client ID, Tenant ID and Secret value. This will be used in next stage for authentication. We’ll need to create a custom RBAC role which has permission to send email. We’ll clone reader role.

 

picture7.jpg

 

And we’ll be adding two actions which is present in Azure Communication service resource provider.

 

picture8.jpg

 

Once the Role is created we’ll need to assign this to service principal

picture9.jpgpicture10.jpg

 

Test SMTP Relay via Powershell

 

That’s all, now you’ll need to find out the sender email. Which is default [email protected]

 

picture10-1.jpgpicture10-2.jpg

 

Note: As you can see in the screenshot Add button is greyed out. You can add custom sender email by sending couple of emails from the default email address and then raising support case. support engineer can help you change the tier to higher which will allow you to add more custom email address.

 

You’ll need credentials to authenticate to the service.

 

  • Username is < Azure Communication Services Resource name>. < Entra Application ID>. < Entra Tenant ID>
  • Password is the client secret which you’ve generated.
  • Port that we’ll need to use is 587
  • SMTP server address is smtp.azurecomm.net

 

Now you can use any third party application to send email via the above parameters. To showcase we can use PowerShell with the same parameters to send emails.

 

picture11.jpgpicture12.jpg

 

Conclusion: I trust this guide helps you in configuring SMTP relay and send emails from your custom application without any change to the application/code.

 

Happy Learning!

 

Personal Blog post of SMTP relay: 
Send emails via SMTP relay with Azure Communication Service

Find similar tech blog on my personal blog
https://www.azuredoctor.com/ 

Published on:

Learn more
Azure Communication Services Blog
Azure Communication Services Blog

Azure Communication Services Blog articles

Share post:

Related posts

Announcing Azure Cosmos DB Integration with LangChain.js!

Announcing Azure Cosmos DB Vector Store Integration with LangChain.js! We’re simplifying AI app development by integrating Azure Cosmos ...

1 day ago

Scale Your Database Workloads with Multishard Clusters in vCore-based Azure Cosmos DB for MongoDB

We’re excited to introduce significant enhancements to vCore-based Azure Cosmos DB for MongoDB with the release of multishard clusters preview...

1 day ago

Transform Your Azure Container Apps with Bulletproof Security

In this post, we explore how to transform your Azure Container Apps with unshakable security. Learn how to master secrets management, optimize...

2 days ago

Optimize Azure Landing Zone with Azure Virtual Network Manager IP Address Management

Optimize Azure Landing Zone with Azure Virtual Network Manager IP Address Management What you will learn from this blog This blog explores how...

2 days ago

Announcing UNLIMITED Public Preview of Metadata Caching for Azure Premium SMB/REST File Shares

Azure Files is excited to announce the Unlimited public preview of Metadata Caching for the premium SMB/REST file share tier.  Unlimited ...

2 days ago

Dominate your industry and boost performance using Azure AI tools and skilling

As AI technologies continue to rapidly evolve, developers have the exciting opportunity to stay ahead by continually learning and adapting. Wi...

3 days ago

Azure DevOps – EPICS vs FEATURES vs USER STORIES vs Tasks vs Bugs

Today, we’re diving into Epics, Features, User Stories, Tasks and Bugs and the main differences between them. You will learn when to use...

3 days ago

Discover the New Azure Cosmos DB Samples Gallery!

We are thrilled to introduce the Azure Cosmos DB Samples Gallery —your ultimate destination for top-tier Azure Cosmos DB samples, technical gu...

3 days ago
Stay up to date with latest Microsoft Dynamics 365 and Power Platform news!
* Yes, I agree to the privacy policy