Hello @Rohan Sirimalla,
Azure blocks outbound SMTP connections on TCP port 25 for all deployed virtual machines by default. This is a security measure designed to protect Microsoft’s platform, align with industry standards, and safeguard both customers and partners.
Since you're using a non-enterprise subscription, specifically a Student plan, this port restriction is expected behavior.
However, for learning purposes, you can use an authenticated SMTP relay service, which typically communicates over TCP port 587. These services are designed to maintain good IP and domain reputation, reducing the chances that your messages are marked as spam or rejected by external domains. SendGrid is one example, though there are several other options available. These services are fully supported in Azure across all subscription types.
For users with Enterprise Dev/Test subscriptions, it is possible to request the removal of the port 25 block. This can be done by navigating to the “Diagnose and Solve” blade within the Azure Virtual Network resource in the Azure Portal. Running the "Cannot send email (SMTP-Port 25)" diagnostic will automatically exempt qualified subscriptions. Once the exemption is granted, the affected VMs must be stopped and restarted for the change to take effect.
Since you're using a student subscription, this exemption option is unfortunately not available. We recommend using an SMTP relay service as the best alternative in your case- https://learn.microsoft.com/en-us/azure/virtual-network/troubleshoot-outbound-smtp-connectivity?source=recommendations#enterprise-and-mca-e
Please let us know what is still needed in the comments so the question can be answered.