私は数日以来このバグに取り組んでおり、おそらく誰かがこの問題についていくつかの手がかりを与えることができます:
MailKit.Net.Smtp.SmtpStream.ReadAheadAsync(Boolean doAsync, CancellationToken cancelToken) で MailKit.Net.Smtp.SmtpStream.ReadResponseAsync(Boolean doAsync, CancellationToken cancelToken) で MailKit.Net.Smtp.SmtpClient.ConnectAsync(String host, Int32 port, C:\Users\Louis\Source\Repos\SafetyStudio\SafetyStudio\Services\Courriels\EmailService.cs:line 58 | の SafetyStudio.Services.Courriels.EmailService.Send(EmailMessage emailMessage) SMTP サーバーが予期せず切断されました。! メールキット
//Be careful that the SmtpClient class is the one from Mailkit not the framework!
using (var emailClient = new SmtpClient())
{
try
{
//The last parameter here is to use SSL (Which you should!)
await emailClient.ConnectAsync(_emailConfiguration.SmtpServer, _emailConfiguration.SmtpPort, MailKit.Security.SecureSocketOptions.None);
//Remove any OAuth functionality as we won't be using it.
emailClient.AuthenticationMechanisms.Remove("XOAUTH2");
await emailClient.AuthenticateAsync(_emailConfiguration.SmtpUsername, _emailConfiguration.SmtpPassword);
await emailClient.SendAsync(message);
await emailClient.DisconnectAsync(true);
emailClient.Dispose();
}
catch (Exception ex)
{
this.logger.LogError($"Erreur dans l'envoi d'un courriel {ex}");
return ex;
}
return null;
}
ポート25と同じエラーで試します。TSL の場合は 587。私は有効な証明書を持っています。
"EmailConfiguration": {
"SmtpServer": "servername",
"SmtpPort": 587,
"SmtpUsername": "aaaaaaaaaaa",
"SmtpPassword": "ssssssssss!",
"PopServer": "popserver",
"PopPort": 995,
"PopUsername": "popusername",
"PopPassword": "poppassword"