我正在使用mailkit在Asp.net Core中发送邮件 这是我的代码
var emailMessage = new MimeMessage();
emailMessage.From.Add(new MailboxAddress("Gorrolo", "gorollobikes@gmail.com"));
emailMessage.To.Add(new MailboxAddress("", email));
emailMessage.Subject = subject;
emailMessage.Body = new TextPart("HTML") { Text = message };
using (var client = new SmtpClient())
{
client.LocalDomain = "http://localhost:54850";
await client.ConnectAsync("smtp.gmail.com", 465, false);
client.Authenticate("Myemail", "Mypassword");
client.Send(emailMessage);
//await client.emailMessage(emailMessage).ConfigureAwait(false);
//await client.DisconnectAsync(true).ConfigureAwait(false);
}
在
行await client.ConnectAsync("smtp.gmail.com", 465, false)
调试器播放以下错误 SMTP服务器意外断开连接
请提出一些可能的解决方案