It's possible that the issue with sending email in your web application hosted on Azure is due to the SMTP server name or port number being incorrect. When publishing your site to a hosting provider, the SMTP server name might change to localhost
, which means you may need to change the SMTP server name as part of your publishing process. Additionally, some providers require the use of port 587 or another port instead of port 25. Double-check with the owner of the SMTP server what port number they expect you to use.
It's also worth noting that Microsoft recommends using authenticated SMTP relay services to send email from Azure VMs or from Azure App Service. These services are used to maintain IP and domain reputation to minimize the possibility that external domains reject your messages or put them in the SPAM folder.
References: