none
Azure Function - SMTP error RRS feed

  • Question

  • Had Mail Function that has been working fine for months. Today I am getting the following error.

    Exception while executing function: Functions.QueueTriggerNotifications
    Microsoft.Azure.WebJobs.Host.FunctionInvocationException : Exception while executing function: Functions.QueueTriggerNotifications ---> System.Reflection.TargetInvocationException : Exception has been thrown by the target of an invocation. ---> System.Net.Mail.SmtpException : The SMTP server requires a secure connection or the client was not authenticated. The server response was: 5.7.57 SMTP; Client was not authenticated to send anonymous mail during MAIL FROM [SN4PR0201CA0013.namprd02.prod.outlook.com]

    What is going on here?

    Wednesday, February 7, 2018 5:31 PM

Answers

  • If your code hasn't changed I'd recommend trying the curl option.

    1. Navigate to console via the Platform features under the Function app.

    2. Type touch blah.txt or whatever you want to call the file (touch creates a new file)

    3. Run the command i sent previously with the values changed to your respective endpoints, email and password ect. Since you are only testing the authentication piece you can leave the txt file blank and just have dummy values for the -from and -to address. The -v switch will output verbose logging to better pinpoint what the issues is.

    Wednesday, February 7, 2018 6:20 PM

All replies

  • It may be helpful to share a snippet of code where you are making the call with any sensitive data removed. From the error it sounds like your email/password combination is incorrect. The error as you can see is coming an Exchange server  [SN4PR0201CA0013.namprd02.prod.outlook.com] so its most likely not an issue on the function app side platform side but rather something at a code level. In the past I've tested SMTP issues with curl. You'll just need to add a dummy file in the directory you are running the curl command from called blah.txt or whatever you want.

    curl --connect-timeout 15 -v --insecure "smtp://smtp.office365.com:587" -u "email:password" --mail-from "emailFrom" --mail-rcpt "emailTo" --ssl --upload-file blah.txt

    Wednesday, February 7, 2018 5:47 PM
  •    MailAddress toDan = new MailAddress("****0122@vtext.com");
       // US Cellular - Jeff
       MailAddress toJeff = new MailAddress("*****2296@email.uscc.net");
       MailAddress from = new MailAddress("*****ARNING@Storm-GPS.US");
       MailMessage message = new MailMessage(from, toDan);
       message.To.Add(new MailAddress("******22296@email.uscc.net", "Jeff ***"));

         SmtpClient client = new SmtpClient("smtp.live.com");
         client.Port = 587;
         client.UseDefaultCredentials = false;
         client.DeliveryMethod = SmtpDeliveryMethod.Network;
         client.Credentials = new System.Net.NetworkCredential("Dan@Storm-GPS.US", "*******");

         client.EnableSsl = true;

         client.Send(message);

    This code was working fine.

    Wednesday, February 7, 2018 5:56 PM
  • If your code hasn't changed I'd recommend trying the curl option.

    1. Navigate to console via the Platform features under the Function app.

    2. Type touch blah.txt or whatever you want to call the file (touch creates a new file)

    3. Run the command i sent previously with the values changed to your respective endpoints, email and password ect. Since you are only testing the authentication piece you can leave the txt file blank and just have dummy values for the -from and -to address. The -v switch will output verbose logging to better pinpoint what the issues is.

    Wednesday, February 7, 2018 6:20 PM