-
Couldn't load subscription status.
- Fork 5.2k
Closed
Description
Description
Met exception when sending email on .Net 8.
Reproduction Steps
using var mailMessage = new MailMessage();
mailMessage.From = new MailAddress("[email protected]", "FromName");
mailMessage.To.Add("[email protected]");
mailMessage.Subject = "Test Subject";
mailMessage.Body = "Test Body";
ServicePointManager.SecurityProtocol = SecurityProtocolType.Tls12;
using var smtpClient = new SmtpClient("smtp.office365.com", 587);
smtpClient.Credentials = new NetworkCredential("[email protected]", "Password");
smtpClient.DeliveryMethod = SmtpDeliveryMethod.Network;
smtpClient.EnableSsl = true;
smtpClient.Timeout = 5000;
smtpClient.SendCompleted += (sender, e) =>
{
Console.WriteLine(e.Error?.Message ?? string.Empty);
};
await smtpClient.SendMailAsync(mailMessage);
Console.ReadLine();Expected behavior
Send email successfully.
Actual behavior
Exception thrown from await smtpClient.SendMailAsync(mailMessage);
System.Net.Mail.SmtpException: 'The server returned an invalid response to the EHLO command.'
Regression?
No response
Known Workarounds
No response
Configuration
No response
Other information
Same code works well on .Net 7 and .Net 6, but never work on .Net 8.
F1schk0pp, devFrame, WeihanLi, WendeHammer and aliaksandrviarshelcampersau