Hello @Li Zhen (NCS) ,
Welcome to Microsoft Q&A Platform. Thank you for reaching out & hope you are doing well.
I understand that you would like to know if there is any Outbound SMTP restriction in Azure.
Out of the 2 options you have specified, option 1 has restriction on the subscription type supported for port 25 outbound SMTP connectivity. Option 2 doesn't have any restriction.
Outbound email messages that are sent directly to external domains (such as outlook.com and gmail.com) from a virtual machine (VM) are made available only to certain subscription types in Microsoft Azure.
- For VMs that are deployed in standard Enterprise Agreement subscriptions, the outbound SMTP connections on TCP port 25 will not be blocked.
- For Enterprise Dev/Test subscriptions, port 25 is blocked by default. It is possible to have this block removed. To request to have the block removed, go to the Cannot send email (SMTP-Port 25) section of the Diagnose and Solve blade in the Azure Virtual Network resource in the Azure portal and run the diagnostic. This will exempt the qualified enterprise dev/test subscriptions automatically. After the subscription is exempted from this block and the VMs are stopped and restarted, all VMs in that subscription are exempted going forward. The exemption applies only to the subscription requested and only to VM traffic that is routed directly to the internet.
- For all other subscription types, the Azure platform will block outbound SMTP connections on TCP port 25 for deployed VMs.
If you're using a non-enterprise subscription type, it is recommended to use an authenticated SMTP relay service to send email from Azure VMs or from Azure App Service. (These relay services typically connect through TCP port 587, but they support other ports.)
Another restriction:
- Sending email on Port 25 is unsupported for all other Azure Platform-as-a-Service (PaaS) resources.
NOTE: It is possible to use port 25 for outbound communication on Azure App Service and Azure Functions through the virtual network integration feature or when using App Service Environment v3. However, the subscription limitations described above still apply.
Please refer the below article to know more about the outbound SMTP connectivity in Azure:
https://learn.microsoft.com/en-us/azure/virtual-network/troubleshoot-outbound-smtp-connectivity
Kindly let us know if the above helps or you need further assistance on this issue.
Please "Accept the answer" if the information helped you. This will help us and others in the community as well.