When you use any email service, there is a limitation to sending bulk emails in a day. If you are using the o365 product, you cannot use that product for sending bulk mail. Even if you go to Microsoft, they will give you the same answer. Then what?

Azure has one more service to overcome that issue. The service name is Azure Communication Service. This service we can use to send emails in bulk. You send bulk emails mostly for bookkeeping, simple surveys, and marketing. improve your time-to-market with scalable, reliable email capabilities with your own SMTP domains. Your Application uses Rest API and Client library SDKs to connect Azure Communication service to send these emails.

Azure Communication Flow Diagram
Azure Communication Flow Diagram

Other than email service, this service can be used to make audio/video calling, text chat, and SMS that easily integrate with your application.

Today we are going to see how to configure Azure communication service without having any prior knowledge of Email services.

High-Level Steps:

  1. Create Azure communication service
  2. Create an email communication service
  3. Add domain
  4. Verify DNS records
  5. Integration between two Communication Services
  6. Email Testing
  7. Monitoring Email Events

Pre-requisite:

  • An Azure account with an active subscription
  • Contributor access on the Azure portal
  • Access to domain hosting site to add DNS records if a custom domain is chosen

Installation steps:

  1. Create Azure Communication Service

Creating an Azure Communication service is very easy, You have to login into the Azure portal. Search for Azure communication service, provide a subscription, and resource group. Type the resource name and select the data location from the drop-down list. This location determines where data will be stored. After creating the service, it will generate the endpoint, keys, and connection string.

Communication Service Creation
Communication Service Creation

2. Create an Email Communication Service

Search for email communication service in the search bar of the portal. Select the subscription name and resource group where you want to create the service. the region is global by default. Keep data location as same as the communication service. This service is still in preview and available in the United States only.

Email Communication Service Creation
Email Communication Service Creation

3. Add Domain

Open Communication service, go to the provision domain option. Click to add domain, and you get two options, either Azure managed domain or custom domain. In this demo, I am going with a custom domain. When you select custom domain, it will ask you to fill in domain detail which you can verify at a later stage.

Custom Domain Addition
Custom Domain Addition

4. Verify DNS records

In the previous screen, you added the public domain, but now you have to configure them one by one. Configuring means you have to add TXT or CNMAE records in your public domain hosting server. To provide more security to your email and you need to add DNS records for SPF and DKIM. Basically, you have to add 4 records (two TXT and two CNAME). Domain verification takes 15-20 min. You will see the below screen after verification.

Domain Verification
Domain Verification

5. Integration between two Communication Services

Azure allows only connecting the domains in the same geography. Please ensure that the Data location for the Communication service resource and Email Communication service Resource are the same.

Go back to the Azure communication service, and select domains from the email section. You need to open connect domain option. Provide details of subscription, resource group, email service, and verified domain. Email service is nothing but your Email communication service resource. Only verified domains will be visible to choose from.

Communication Service Integration
Communication Service Integration

6. Email Testing

Go to the overview of the Azure communication service, and copy the endpoint, access keys, or connection string. Use the required details in the application code to send a mail. You will get the Form email id from the Email Communication Service where you have configured your public custom domain. It is available in the overview section of it.

Azure Communication Services Email client libraries can be used to add transactional Email support to your applications.

I created the below python script to send a mail. You have to update the connection string, From email id and To email id in the script for sending mail.

Python Script to Send a mail
Python Script to Send a mail
Received mail
Received mail

7. Monitoring Email Events

If you need to check email events, you need to create an event subscription. The first step is to create an event grid service and web app to proceed. An event grid is required to collect events and a web app is required for webhook which triggers based on events. In the configuration, you can select email-related event types, Email Delivery Report Received events, and Email Engagement Tracking Report Received events.

Creation of Event Subscription
Creation of Event Subscription

After the above configuration is done, you will send multiple emails, you can see the tractions below. You will find how many emails have been sent. Out of which how many are delivered, failed, filtered spam, and quarantined?

Collected Email Events
Collected Email Events

This service is still in preview so do not use it for the production environment but you can use it in the lower environments. This service has made life easy for developers and testers to check application email functionality.

Thanks for reading, Keep following #MultiCloudSagar for new update.