Hello Vahabudeen Pathiyampara,
In Azure, outbound SMTP traffic on TCP port 25 is blocked by default for most subscription types, including from VMs.
This is confirmed in MS documentation-
"The Azure platform blocks outbound SMTP connections on TCP port 25 for deployed VMs. This block is to ensure better security for Microsoft partners and customers, protect Microsoft's Azure platform, and conform to industry standards."
Troubleshoot outbound SMTP connectivity in Azure Microsoft Learn
Even though Office 365 allows SMTP relay over port 25, Azure VMs cannot send unauthenticated email over port 25 unless certain conditions are met.
How to fix it?
Ans- You have two options-
Option 1: Instead of port 25, you should configure your application or SMTP agent to use SMTP submission over port 587 with authentication.
Microsoft officially recommends this method:
"We recommend you use authenticated SMTP relay services to send email from Azure VMs. Connections to authenticated SMTP relay services are typically on TCP port 587 which isn't blocked."
Troubleshoot outbound SMTP connectivity in Azure Microsoft Learn
For Office 365 SMTP submission setup, Microsoft states:
"Use SMTP AUTH client submission (Option 1) to send emails from devices or applications through Microsoft 365 or Office 365. SMTP AUTH uses TCP port 587."
Set up SMTP client submission in Microsoft 365 | Microsoft Learn
You can authenticate with an Office 365 licensed mailbox to relay emails securely.
Option 2: If your Azure subscription is an Enterprise Agreement (EA) or Microsoft Customer Agreement for Enterprise (MCA-E) subscription, you can request to have the port 25 block removed.
As per Microsoft document-
"For VMs deployed in standard Enterprise Agreement or MCA-E subscriptions, the outbound SMTP connections on TCP port 25 aren't blocked."
"To request to have the block removed, go to the Diagnose and Solve Problems section of the Virtual Network resource in the Azure portal and run the diagnostic."
Troubleshoot outbound SMTP connectivity in Azure Microsoft Learn
After the unblock request is approved, you must stop, deallocate, and restart the VM to apply the new network policies.
Hope this clarifies your query.