私はAsp.netコアWebアプリケーションを持っているとMailkitを使用して電子メールを送信する:Asp.netコアmailkit
emailMessage.From.Add(new MailboxAddress("John", "[email protected]"));
emailMessage.To.Add(new MailboxAddress("Doe", email));
emailMessage.Subject = subject;
emailMessage.Body = new TextPart("plain") { Text = message };
using (var client = new SmtpClient())
{
client.ServerCertificateValidationCallback = (s, c, h, e) => true;
client.Connect("smtp-mail.outlook.com", 587, false);
client.AuthenticationMechanisms.Remove("XOAUTH2");
client.Authenticate("[email protected]", "password");
client.Send(emailMessage);
client.Disconnect(true);
}
それがうまく送信だVS上とlocalYアプリケーションを実行中。しかし、私はそれがこのようなメッセージで失敗の電子メール送信時にAzureのアプリケーションサービスにアップロードする場合:
SmtpProtocolException: The SMTP server has unexpectedly disconnected.
MailKit.Net.Smtp.SmtpStream.ReadAhead(CancellationToken cancellationToken)
MailKit.Net.Smtp.SmtpStream.ReadResponse(CancellationToken cancellationToken)
MailKit.Net.Smtp.SmtpClient.SendCommand(string command, CancellationToken cancellationToken)
MailKit.Net.Smtp.SmtpClient.Authenticate(Encoding encoding, ICredentials credentials, CancellationToken cancellationToken)
MailKit.MailService.Authenticate(string userName, string password, CancellationToken cancellationToken)
誰もがそれを修正する方法を知っていますか?