Loading...

Send emails via SMTP relay with Azure Communication Service

Send emails via SMTP relay with Azure Communication Service

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.

Though Azure Communication service supports sending emails outbound but currently it requires you to integrate it via the ACS SDK that Microsoft provide. 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 ACS - SMTP relay built into Email communication service.

Azure Communication Service supports different types of notifications, SMTP relay in ACS is now Generally available and this blog post is simple step by step instructions of how you can quickly test the service and then migrate from Sendgrid or another service you’re using to native ACS – Email communication service for better operational experience and support.

Create Azure Communication Service Account


First step you’ll need to do is to create an ACS account. This is a parent service which has multiple notification services inside it(Chat,SMS, Email etc). Email communications service is one of them.

picture1.jpg

Create Email communication service

 

We’ll have to create ECS which is the actual service that holds configuration details.

 

picture2.jpg

Add a custom domain to ECS

 

ECS provides Azure managed domain which look like this “GUID.azurecomm.net” this provides limited volume of email hence using custom domain is preferred. Once you add a custom domain, the UI provides you with TXT record which you’ll need to create in your Name server. This would take 15 minutes to verify the domain


picture3.jpgpicture4.jpg

Once domain is verified the screen looks like this, you’ll have to 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 to ACS Account

 

Once email is validated we’ll need to attach ECS to ACS.

 

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

Azure Communication Services Ideas Board: Share your feedback with the product team

Innovation is not a solitary pursuit, and we recognize that some of the best ideas come from you, our Azure Communication Services community. ...

1 year ago

Engage with the Azure Community Services Ideas Board: Your Voice Matters

Innovation is not a solitary pursuit, and we recognize that some of the best ideas come from you, our Azure Communication Services community. ...

1 year ago

Part 2 - Multichannel notification system using Azure Communication Services and Azure Functions

In the first part of this topic, we setup all the Azure resources like the Azure Communication Services for Email, SMS, WhatsApp for...

1 year ago

Part 1 - Multichannel Notification System with Azure Communication Services and Azure Functions

In the interconnected digital era, it's crucial for businesses and services to communicate effectively with their audience. A robust notificat...

1 year ago

Building a WhatsApp AI bot for customer support

Building a WhatsApp AI Bot for customer support   In this blog post, we’ll explore how to build a customer support application that integ...

1 year ago

Azure Communication Services September 2024 Feature Updates

The Azure Communication Services team is excited to share several new product and feature updates released in August 2024. (You can view previ...

1 year ago

Azure Communication Services at the DEVIntersection Conference

Join us for the DEVintersection Conference from September 10 to 12, 2024, in Las Vegas, Nevada. This event gathers technology enthusiasts from...

1 year ago

Azure Communication Services June 2024 Feature Updates

Data Retention with Chat threads   Developers can now create chat threads with a retention policy between 30 and 90 days.  This feat...

1 year ago

Azure Communication Services August 2024 Feature Updates

The Azure Communication Services team is excited to share several new product and feature updates released in July 2024. (You can view previou...

1 year ago

Anywhere365 integrates Azure Communication Services into their Dialogue Cloud Platform

  Every day, companies aim to help their customers realize the most value from their products and services. They do this by providing ef...

2 years ago

Newsletter

Get the latest Dynamics 365 and Power Platform content in your inbox

A curated digest of community blogs, product news, videos, and podcasts — delivered without the noise.

Weekly updates Unsubscribe anytime Fresh community picks
We use your email only for the newsletter and you can unsubscribe at any time.
By subscribing, you agree to the privacy policy.