Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

.Net 8 Preview sending email exception #91377

Closed
CuteLeon opened this issue Aug 31, 2023 · 10 comments · Fixed by #91750
Closed

.Net 8 Preview sending email exception #91377

CuteLeon opened this issue Aug 31, 2023 · 10 comments · Fixed by #91750

Comments

@CuteLeon
Copy link

CuteLeon commented Aug 31, 2023

Description

Met exception when sending email on .Net 8.

Reproduction Steps

using var mailMessage = new MailMessage();
mailMessage.From = new MailAddress("systems@xxxxxxx.com.cn", "FromName");
mailMessage.To.Add("receiver@xxxxxx.com.cn");
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("systems@xxxxxx.com.cn", "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.

@ghost ghost added the untriaged New issue has not been triaged by the area owner label Aug 31, 2023
@ghost
Copy link

ghost commented Aug 31, 2023

Tagging subscribers to this area: @dotnet/ncl
See info in area-owners.md if you want to be subscribed.

Issue Details

Description

Met exception when sending email on .Net 8.

Reproduction Steps

using var mailMessage = new MailMessage();
mailMessage.From = new MailAddress("systems@xxxxxxx.com.cn", "FromName");
mailMessage.To.Add("receiver@xxxxxx.com.cn");
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("systems@xxxxxx.com.cn", "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

Exception thrown from await smtpClient.SendMailAsync(mailMessage);

System.Net.Mail.SmtpException: 'The server returned an invalid response to the EHLO command.'

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.

Author: CuteLeon
Assignees: -
Labels:

area-System.Net

Milestone: -

@MihaZupan MihaZupan added the bug label Aug 31, 2023
@MihaZupan MihaZupan added this to the 8.0.0 milestone Aug 31, 2023
@ghost ghost removed the untriaged New issue has not been triaged by the area owner label Aug 31, 2023
@MihaZupan
Copy link
Member

I can reproduce the issue - I'm able to send mail with the provided repro on 6.0 and 7.0, but hit the exception on 8.0.

@F1schk0pp
Copy link

Same here. In .NET 6.0 and 7.0 it works but with 8.0 i got the same exception.

@devFrame
Copy link

devFrame commented Sep 1, 2023

getting an EHLO from the other side too :)

@CuteLeon
Copy link
Author

CuteLeon commented Sep 5, 2023

Hi @MihaZupan, is there any progress or plan on this issue?

@ManickaP ManickaP self-assigned this Sep 5, 2023
@ManickaP
Copy link
Member

ManickaP commented Sep 5, 2023

@CuteLeon I'm looking at the issue, I was able to reproduce as well. I'll let you know here when I find out the root cause.

@CuteLeon
Copy link
Author

CuteLeon commented Sep 6, 2023

@CuteLeon I'm looking at the issue, I was able to reproduce as well. I'll let you know here when I find out the root cause.

That's fantastic and thank you very much.

@ghost ghost added the in-pr There is an active PR which will close this issue when it is merged label Sep 7, 2023
@ghost ghost removed the in-pr There is an active PR which will close this issue when it is merged label Sep 8, 2023
@ghost ghost added the in-pr There is an active PR which will close this issue when it is merged label Sep 8, 2023
@karelz
Copy link
Member

karelz commented Sep 8, 2023

Reopening to track the backport to 8.0 (RC2).

@karelz karelz reopened this Sep 8, 2023
@F1schk0pp
Copy link

Thank you very much @ManickaP :)

@ghost ghost removed the in-pr There is an active PR which will close this issue when it is merged label Sep 14, 2023
@karelz
Copy link
Member

karelz commented Sep 14, 2023

Fixed in main (9.0) in PR #91750 and in 8.0 (RC2) in PR #91794

@karelz karelz closed this as completed Sep 14, 2023
@ghost ghost locked as resolved and limited conversation to collaborators Oct 14, 2023
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

Successfully merging a pull request may close this issue.

6 participants