SMTP 5.7.57 error when trying to send email via Office 365

In my case after I tried all this suggestion without luck, I contacted Microsoft support, and their suggestion was to simply change the password.

This fixed my issue.

Note that the password wasn't expired, because I logged on office365 with success, however the reset solved the issue.

Lesson learned: don't trust the Office 365 password expiration date, in my case the password would be expired after 1-2 months, but it wasn't working. This leaded me to investigate in my code and only after a lot of time I realized that the problem was in the Office365 password that was "corrupted" or "prematurely expired".

Don't forget every 3 months to "refresh" the password.


To aid in debugging, try temporarily switching to MailKit and using a code snippet such as the following:

using System;

using MailKit.Net.Smtp;
using MailKit.Security;
using MailKit;
using MimeKit;

namespace TestClient {
    class Program
    {
        public static void Main (string[] args)
        {
            var message = new MimeMessage ();
            message.From.Add (new MailboxAddress ("", "[email protected]"));
            message.To.Add (new MailboxAddress ("", "[email protected]"));
            message.Subject = "Test message";

            message.Body = new TextPart ("plain") { Text = "This is the message body." };

            using (var client = new SmtpClient (new ProtocolLogger ("smtp.log"))) {
                client.Connect ("smtp.office365.com", 587, SecureSocketOptions.StartTls);

                client.Authenticate ("[email protected]", "password");

                client.Send (message);
                client.Disconnect (true);
            }
        }
    }
}

This will log the entire transaction to a file called "smtp.log" which you can then read through and see where things might be going wrong.

Note that smtp.log will likely contain an AUTH LOGIN command followed by a few commands that are base64 encoded (these are your user/pass), so if you share the log, be sure to scrub those lines.

I would expect this to have the same error as you are seeing with System.Net.Mail, but it will help you see what is going on.

Assuming it fails (and I expect it will), try changing to SecureSocketOptions.None and/or try commenting out the Authenticate().

See how that changes the error you are seeing.


Be sure you're using the actual office365 email address for the account. You can find it by clicking on the profile button in Outlook365. I wrestled with authentication until I realized the email address I was trying to use for authentication wasn't the actual mailbox email account. The actual account email may have the form of: [email protected].