【发布时间】:2017-09-21 22:47:12
【问题描述】:
如果我通过第三方托管服务提供商(例如 A2 Hosting)托管 asp.net 核心应用程序,是否可以使用它来发送带有 Mail Kit 的邮件?我尝试了很多不同的东西,client.Connect 只是挂起并最终引发异常。 Ex 为空。
这是我的代码:
using (var client = new SmtpClient())
{
// For demo-purposes, accept all SSL certificates (in case the server supports STARTTLS)
client.ServerCertificateValidationCallback = (s, c, h, e) => true;
client.Connect("mail.mydomain.com", 25, false);
// Note: since we don't have an OAuth2 token, disable
// the XOAUTH2 authentication mechanism.
client.AuthenticationMechanisms.Remove("XOAUTH2");
// Note: only needed if the SMTP server requires authentication
client.Authenticate("contact@mydomain.com", "PASSWORD");
client.Send(message);
client.Disconnect(true);
}
【问题讨论】:
标签: asp.net email asp.net-core asp.net-core-mvc mailkit