I am using mailkit to send a mail in ASP.NET Core Here is my code
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);
}
in the line
await client.ConnectAsync("smtp.gmail.com", 465, false)
Debugger sowing the following error The SMTP server has unexpectedly disconnected