How can I open port 25 to allow sending email from Azure VM

MFP Admin 0 Reputation points
2025-04-09T03:30:20.7733333+00:00

Hello,

Is it possible to open port 25, to enable an application running on an Azure VM to send email using the domain's MX record address as the SMTP server? I've had this setup running successfully on-premises, and have since moved the server into Azure.

Thank you!

Azure Virtual Machines
Azure Virtual Machines
An Azure service that is used to provision Windows and Linux virtual machines.
9,019 questions
{count} votes

2 answers

Sort by: Most helpful
  1. Mounika Reddy Anumandla 6,570 Reputation points Microsoft External Staff Moderator
    2025-04-09T04:05:22.5+00:00

    Hi MFP Admin,

    On-premises, sending email directly to recipient mail servers (using DNS MX lookups and port 25) is usually unrestricted. But once the server was moved into Azure, that behavior changed because Azure VMs can't send outbound traffic over port 25 by default, regardless of whether you're using a public MX record or a custom domain.

    The ability to send outbound emails via port 25 depends on your subscription type:

    • Enterprise Agreement (EA) and Microsoft Customer Agreement for Enterprise (MCA-E) Subscriptions: Outbound SMTP connections on port 25 are allowed by default. However, for Enterprise Dev/Test subscriptions, port 25 is blocked by default but can be unblocked upon request.
    • Other Subscription Types (like Pay-As-You-Go): Outbound traffic on port 25 is blocked by default, and this restriction cannot be lifted

    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.

    Using these email delivery services on authenticated SMTP port 587 isn't restricted in Azure, regardless of the subscription type. https://learn.microsoft.com/en-us/azure/virtual-network/troubleshoot-outbound-smtp-connectivity

    similar references: https://learn.microsoft.com/en-us/answers/questions/1679480/virtual-machine-smtp-(25)-port-blocked-fix

    Hope this helps!

    Let me know if you have any further queries!

    Hope the information provided is helpful to you, I would request you to kindly please consider accepting it as an answer and do a thumbs up at “Was it helpful”. This in turn will benefit other community members with similar scenario navigate better to right solution.User's image

    0 comments No comments

  2. Alex Burlachenko 9,780 Reputation points
    2025-05-13T13:34:42.9833333+00:00

    Dear MFP Admin

    thank you for posting your question on the Q&A portal!

    First, I want to mention that Microsoft restricts outbound port 25 connections from Azure Virtual Machines by default to prevent spam. However, there are ways to request an exception if you have a legitimate need, like running an application that sends emails. You can find more details in Microsoft’s official documentation on Azure outbound SMTP connectivity.

    To get this working, you’ll need to submit a support request in the Azure portal to remove the block on port 25. Just go to Help + Support > New Support Request, and choose the issue type related to service limits. Microsoft will review your case, and if approved, they’ll allow outbound SMTP traffic.

    Alternatively, you can use a relay service like Azure Communication Services or a third-party SMTP provider (such as SendGrid) that doesn’t require port 25. This is often a simpler solution since many email providers block direct sends from cloud VMs due to abuse risks. Microsoft recommends this approach in their SMTP relay documentation.

    If you still prefer using your own SMTP server, make sure your VM’s network security group allows outbound traffic on port 25. You can check this under Networking in your VM settings. Here’s a guide on configuring NSGs in Azure.

    Hope this helps.

    Best regards,
    Alex
    P.S. If my answer help to you, please Accept my answer
    PPS That is my Answer and not a Comment
    https://ctrlaltdel.blog/
    
    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.