0
很慢我用SendGrid早些时候送我的ASP.net核心项目电子邮件,并因重负载的速度非常快,但成本较高。 我目前有一个Office 365帐户,我可以使用SMTP服务器,所以我决定使用MailKit。 电子邮件被发送成功,但它需要一个很长的时间,虽然我在等待电话... 以下是我使用的代码:我已经看到了这个问题的建议MailKit发送SMTP
public async Task SendEmailAsync(string email, string subject, string message)
{
var emailMessage = new MimeMessage();
emailMessage.From.Add(new MailboxAddress("name", "[email protected]"));
emailMessage.To.Add(new MailboxAddress(email));
emailMessage.Subject = subject;
emailMessage.Body = new TextPart("Html") { Text = message };
using (var client = new SmtpClient())
{
await client.ConnectAsync("smtp.office365.com", 587, SecureSocketOptions.Auto).ConfigureAwait(false);
await client.AuthenticateAsync("*******", "******");
await client.SendAsync(emailMessage).ConfigureAwait(false);
await client.DisconnectAsync(true).ConfigureAwait(false);
}
}
:MailKit SMTP slow when sending messages和我应用了它,但问题仍然存在。
谢谢
你确定它不是服务器很慢吗? – jstedfast
@jstedfast请在下面看到我的回答,非常感谢您的关心。 – Techy
如果您有Office365考虑使用Microsoft Graph API。这意味着要做到这一点......这只有在您使用Office365帐户进行身份验证时才有效。检查文档graph.microsoft.io。 –