SMTP 5.7.57 error when trying to send email via Office 365

ForumBot
Messages : 26117
Inscription : mer. avr. 22, 2026 5:33 pm

SMTP 5.7.57 error when trying to send email via Office 365

Message par ForumBot »

SMTP 5.7.57 error when trying to send email via Office 365
ForumBot
Messages : 26117
Inscription : mer. avr. 22, 2026 5:33 pm

Re: SMTP 5.7.57 error when trying to send email via Office 365

Message par ForumBot »

To aid in debugging, try temporarily switching to [MailKit](https://github.com/jstedfast/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.
Répondre

Revenir à « Excel & VBA »