how do I open smtp port 25 so that email can be received by my azure VM?

Tim Cruise 0 Reputation points
2025-01-14T23:43:56.44+00:00

I opened port 25 on my Azure NSG, but am unable to send mail from external to my azure VM mail server

Azure Virtual Machines
Azure Virtual Machines
An Azure service that is used to provision Windows and Linux virtual machines.
8,242 questions
0 comments No comments
{count} votes

2 answers

Sort by: Most helpful
  1. Manu Philip 18,706 Reputation points MVP
    2025-01-15T04:13:25.9433333+00:00

    Hi Tim Cruise

    It's 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. It's also possible to send port 25 outbound communication through Azure Firewall. Sending email on Port 25 is unsupported for all other Azure Platform-as-a-Service (PaaS) resources. This is in place to prevent abuse of the service and stop spammers etc.+

    Recommended method of sending email

    We recommend you use authenticated SMTP relay services to send email from Azure VMs or from Azure App Service. Connections to authenticated SMTP relay services are typically on TCP port 587 which is not blocked.

    Depending on your subscription type it may be possible to have this block removed by logging a support ticket with Microsoft and requesting the block to be removed for your subscription.

    Hope this helps.


    --please don't forget to upvote and Accept as answer if the reply is helpful--


  2. Mounika Reddy Anumandla 1,555 Reputation points Microsoft Vendor
    2025-01-16T07:02:45.2866667+00:00

    Hi Tim Cruise

    Office 365 sends email to external mail servers using Port 25, and you cannot easily change this to Port 587 because Port 587 is used for email submission from email clients (not server-to-server).

    Since Port 25 is used for server-to-server email traffic, you must ensure that Port 25 is open on the Network Security Group (NSG) associated with your Azure VM.

    Ensure that the mail server running on your Azure VM is configured to listen on Port 25 for incoming SMTP traffic.

    Check if there is any external firewall (either on your Azure VM or an intermediary device like Azure Firewall) that might be blocking Port 25.

    As suggested by Manu Philip, you can configure an SMTP relay server on your Azure VM as an alternative workaround. Follow these steps:

    • Deploy an SMTP relay server (e.g., hMailServer on Windows or Postfix on Linux) on the VM.
    • Configure the relay to forward emails to Office 365 using SMTP AUTH on port 587.
    • In Office 365, set up a connector to allow relay from the VM’s IP address. Set up connectors for secure mail flow.
    • Update the VM’s NSG to allow outbound traffic on port 587 to Office 365.

    For more details, please refer to the below documentation: Troubleshoot outbound SMTP connectivity problems in Azure.

    (These relay services typically connect through TCP port 587, but they support other ports.) These services are used to maintain IP and domain reputation to minimize the possibility that external domains reject your messages or put them to the SPAM folder. SendGrid is one such SMTP relay service, but there are others.

    Let me know if you have any further queries!

    If the comment is helpful, please click "upvote" to let us know.

    0 comments No comments

Your answer

Answers can be marked as Accepted Answers by the question author, which helps users to know the answer solved the author's problem.