E-Mail Sending From Microsoft Azure App Service

Manishk_Optimus 1 Reputation point
2022-04-06T04:24:13.493+00:00

Hello Team

We have our APIs deployed into Azure App Service and we are using the MailJet utility to send mails. We have multiple app environments from where this code is deployed but in one particular environment, we are observing a very high delay in sending the emails around 15 to 30 mins, and sometimes it fails also if we trigger multiple emails.

We are not able to figure out any cause for this as the same code is working fine in other environments. Please let us know the possible reasons for this.

Azure App Service
Azure App Service
Azure App Service is a service used to create and deploy scalable, mission-critical web apps.
8,933 questions
0 comments No comments
{count} votes

2 answers

Sort by: Most helpful
  1. ajkuma 28,036 Reputation points Microsoft Employee Moderator
    2022-04-06T20:24:34.237+00:00

    @Manishk_Optimus ,

    To better assist you on this, just to clarify, since it’s working fine on other multiple apps, was it working fine before on the problematic WebApp, or it’s always been this way?
    || Are all those apps the same framework (Dot.net, Python, etc)? Are those on the same App Service Plan (ASP) or different ASP?

    As I understand multiple apps with the same code; sending email works fine as expected on all, but only one WebApp exhibits delay in email delivery (or fails).

    As quick isolation, you may review these:

    --If the Always On setting is off, please enable it from Azure Portal – Your WebApp > Configuration blade (> General settings).

    --If you’re leveraging lower ASP SKU/tier, scale-up to a higher tier and then test.

    --Review App Service diagnostics (to fetch more details about the issue).

    --You may leverage App Service diagnostics from Azure Portal> Navigate to your App Service app in the Azure Portal.
    --In the left navigation, click on Diagnose and solve problems - Review - “Configuration and Management and “Availability and Performance” options.


  2. Manishk_Optimus 1 Reputation point
    2022-04-08T18:25:49.313+00:00

    We have tried a few things that you have suggested but are still not able to send the emails properly. The main problem is that neither the issue is reproducible locally nor in a sample application where we are using the same email sending logic. So we are also suspecting some app configuration-related issues.

    Actually, this app service is running in a deployment slot along with the other service which is successfully able to trigger mails well without any issue.

    Please find my responses to your questions below

    Yes, It was working well earlier.

    All the apps are having the same framework .Net Core

    The Always ON setting is already ON.

    The logs are sometimes showing the below error

    ---> System.Net.Internals.SocketExceptionFactory+ExtendedSocketException (10060): A connection attempt failed because the connected party did not properly respond after a period of time, or established connection failed because connected host has failed to respond. [::ffff:104.199.96.85]:12345
    at System.Net.Sockets.Socket.DoConnect(EndPoint endPointSnapshot, SocketAddress socketAddress)
    at System.Net.Sockets.Socket.Connect(EndPoint remoteEP)
    at System.Net.Sockets.TcpClient.Connect(IPEndPoint remoteEP)
    at System.Net.Sockets.TcpClient.Connect(String hostname, Int32 port)
    --- End of stack trace from previous location where exception was thrown ---
    at System.Net.Sockets.TcpClient.Connect(String hostname, Int32 port)
    at System.Net.Mail.SmtpConnection.InitializeConnection(String host, Int32 port)
    at System.Net.Mail.SmtpConnection.GetConnection(String host, Int32 port)
    at System.Net.Mail.SmtpClient.Send(MailMessage message)


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.