根据新的谷歌政治https://googleonlinesecurity.blogspot.de/2014/04/new-security-measures-will-affect-older.html我无法发送电子邮件。谷歌认为“不太安全的应用程序”是不使用 OAuth 2.0 的应用程序。
我想用 MailKit 来解决这个问题
var message = new MimeMessage();
message.From.Add(new MailboxAddress("Joey Tribbiani", "noreply@localhost.com"));
message.To.Add(new MailboxAddress("Mrs. Chanandler Bong", "mymail@gmail.com"));
message.Subject = "How you doin'?";
message.Body = new TextPart("plain"){ Text = @"Hey" };
using (var client = new SmtpClient())
{
client.Connect("smtp.gmail.com", 587);
////Note: only needed if the SMTP server requires authentication
client.Authenticate("mymail@gmail.com", "mypassword");
client.Send(message);
client.Disconnect(true);
}
但我有An exception of type 'MailKit.Security.AuthenticationException' occurred in MailKit.dll but was not handled in user code.Additional information: Authentication failed.
我不想更改我的安全设置。因为我希望一切都安全。这就是我开始使用 MailKit 而不是 System.Net.Mail 的原因
我该如何解决?