5.7.1 Client was not authenticated RRS feed

  • Question

  • hey,

    I need to send mail over "daily tasks, and i get the following exception :

    System.Net.Mail.SmtpException: The SMTP server requires a secure connection or the client was not authenticated. The server response was: 5.7.1 Client was not authenticated
       at System.Net.Mail.MailCommand.CheckResponse(SmtpStatusCode statusCode, String response)
       at System.Net.Mail.MailCommand.Send(SmtpConnection conn, Byte[] command, String from)
       at System.Net.Mail.SmtpTransport.SendMail(MailAddress sender, MailAddressCollection recipients, String deliveryNotify, SmtpFailedRecipientException& exception)
       at System.Net.Mail.SmtpClient.Send(MailMessage message)

    I check the user to see if he not a locked, and he doesn't .

    I check the smtp mail server ans he is ok.

    what else can i check? how can i fix this? this is super urgent.

    this is my code :

        MailMessage mess = null;
                Attachment attach = null;
                SmtpClient smtp = null;

                    mess = new MailMessage();

                    smtp = new SmtpClient("smtp.office365.com");

                    smtp.Port = 587;

                    smtp.EnableSsl = true;

                    System.Net.NetworkCredential cred = new System.Net.NetworkCredential("User@mail.com", "Pass");

                    smtp.Credentials = cred;

                    mess.From = new MailAddress("noc-report@hexagontech.co.il");

                    mess.Subject = fileName;

                    smtp.Timeout = 300000;



                catch (SmtpFailedRecipientException exp)
                    elog.WriteEntry(exp.ToString(),EventLogEntryType.Error, 0);

                catch (Exception e)
                    elog.WriteEntry(e.ToString(), EventLogEntryType.Error, 0);



    • Edited by BarShauly Monday, February 24, 2014 9:38 AM
    Monday, February 24, 2014 9:38 AM


All replies

  • Check if the client connector used to connect with the 587 port is allowed to accept authentication on Plain Text.

    Try a relay connector if you want to send the email without the authentication.

    Syed MM Messaging SME - IBM || MCTS || MCSE || MCSA || VCP5 || VCA ||

    • Marked as answer by BarShauly Monday, February 24, 2014 1:00 PM
    Monday, February 24, 2014 10:08 AM
  • how can i check it?

    i tried to use my user (and not a generic user) and it is still with the same exception.

    also, i must use authentication because my smtp mail server is :smtp.office365.com

    Monday, February 24, 2014 10:13 AM
  • Seems the authentication to the O365 isn't validating properly

    new System.Net.NetworkCredential("demo@onmicrosoft.com", "mypassword");

    If I am not wrong the username should be kind of user@onmicrosoft.com

    Syed MM Messaging SME - IBM || MCTS || MCSE || MCSA || VCP5 || VCA ||

    Tuesday, February 25, 2014 7:54 AM
  • Comment out UseDefaultCredentials worked for me.

    See Microsoft Bug: https://connect.microsoft.com/VisualStudio/feedback/details/725279/smtp-tls-authentication-usedefaultcredentials-bug-using-office365-server-as-smart-host

    Wednesday, July 30, 2014 9:25 PM