Skip to content

.Net 8 Preview sending email exception #91377

@CuteLeon

Description

@CuteLeon

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.

Metadata

Metadata

Assignees

Type

No type

Projects

No projects

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions