How to Send Emails Using SMTP Relay with Azure Communication Services. This tutorial covers setting up Azure Communication Services to send emails via SMTP relay, perfect for developers, IT admins, and cloud technicians. A step-by-step guide for developers and IT admins to configure secure email delivery from apps, printers, and IoT devices.
Scroll Down for Video Link
More Posts: Technical Blogs
Why Use Azure SMTP Relay?
- Avoid IP blacklisting by relaying through Microsoft’s trusted servers
- No mail server maintenance – fully cloud-based solution
- Enterprise-grade security with TLS encryption and authentication
- Scalable pricing – pay only for emails sent
Use Cases
- Sending emails from applications (CRM, ERP)
- Configuring “scan to email” on printers
- Sending emails from IoT devices or backend systems
Benefits of Azure SMTP Relay
- Avoids IP blacklisting by relaying through trusted SMTP server
- Secure and authenticated email delivery
- No need to host your own mail server
Prerequisites for Azure SMTP Relay
- Azure subscription (Pay-As-You-Go works)
- Communication Service resource in Azure
- Verified domain (or subdomain) for email
- SMTP client/app/code to send emails
- Open outbound ports (587 recommended, or 25)

Step-by-Step Setup to Send Emails Using SMTP Relay
1. Create Email Communication Service in Azure
- Search for “Email Communication Services” in Azure portal
- Create new resource:
- Resource group: “Email-SMTP-Relay”
- Location: Choose nearest region
- Name: “Email-SMTP-Relay”
- Data location: Select appropriate region
2. Verify Your Domain for SMTP Relay
- Create a subdomain (e.g., newsletters.yourdomain.com)
- In Email Communication Service:
- Add custom domain (newsletters.yourdomain.com)
- Verify domain by adding TXT record to DNS
- Configure SPF and DKIM records (TXT and CNAME records)
Important Note: When adding DKIM records for subdomains, append your subdomain to the Azure-provided domain key (e.g., add “.newsletters” to the domain key value).
3. Create Communication Service
- Search for “Communication Services” in Azure portal
- Create new resource:
- Name: “Newsletter-Service”
- Same resource group as before
- Same location
4. Connect Domain to Communication Service
- In Communication Service, go to “Connect your email domains”
- Select your Email Communication Service resource
- Select your verified domain
5. Set Up Authentication
- Create Azure AD application:
- In Azure AD > App registrations > New registration
- Name: “Newsletter-Delivery-App”
- Accounts in this organization only
- Register
- Create client secret:
- Go to Certificates & secrets
- New client secret (e.g., “Delivery-App-Secret”)
- Copy the secret value (this will be your SMTP password)
- Assign role:
- In Communication Service > Access Control (IAM)
- Add role assignment: “Communication Email Service Owner”
- Select your “Newsletter-Delivery-App” as member
6. Create SMTP Usernames
- In Communication Service > SMTP usernames
- Add username (e.g., “newsletters” or “newsletter-delivery@newsletters.yourdomain.com“)
7. Configure Mail From Addresses
- In Domains > your domain > Mail from addresses
- Default addresses are created (e.g., donotreply@newsletters.yourdomain.com)
- To add more addresses, use Azure CLI:
az communication email domain sender-username create \
--domain-name newsletters.yourdomain.com \
--email-service-name Email-SMTP-Relay \
--resource-group Email-SMTP-Relay \
--sender-username scanner21 \
--display-name "Scanner 21"
Sending Emails
$SMTPServer = "smtp.azurecomm.net"
$SMTPPort = 587 # or 25
$Username = "newsletters" # or your SMTP username
$Password = "your-client-secret-value" # from Azure AD app
$From = "donotreply@newsletters.yourdomain.com"
$To = "recipient@example.com"
$Subject = "Test Email"
$Body = "This is a test email using Azure Communication Services SMTP relay"
$SMTPMessage = New-Object System.Net.Mail.MailMessage($From, $To, $Subject, $Body)
$SMTPClient = New-Object Net.Mail.SmtpClient($SMTPServer, $SMTPPort)
$SMTPClient.EnableSsl = $true
$SMTPClient.Credentials = New-Object System.Net.NetworkCredential($Username, $Password)
$SMTPClient.Send($SMTPMessage)
Troubleshooting
- If emails aren’t sending, check:
- Outbound port 587/25 is open in firewall
- Domain verification is complete (may take 15-20 minutes)
- Newly created sender addresses may take time to activate
- TLS must be enabled when using port 25
Pricing
- Based on number of emails sent and their size
- Example: 1 million 3MB emails ≈ $122/month
- Use Azure pricing calculator for accurate estimates
This solution provides a reliable, cloud-based SMTP relay service that avoids IP blacklisting issues while providing secure email delivery.
How to Send Emails Using SMTP Relay with Azure Communication Services: Video on Techno Tips Learning
Explore our Literature YouTube Channels:

YouTube Channel Link:

YouTube Channel Link:

YouTube Channel Link:

YouTube Channel Link