【发布时间】:2020-04-01 03:16:11
【问题描述】:
我正在尝试向我的 250 位用户发送电子邮件。这是我的代码:
using(var emailClient = new SmtpClient())
{
emailClient.Connect(Configuration.Server, Configuration.Port, Configuration.UseSSL);
emailClient.AuthenticationMechanisms.Remove("XOAUTH2");
emailClient.Authenticate(Configuration.UserName, Configuration.Password);
try
{
foreach(var item in EmailContents)
{
var message = new MimeMessage();
message.To.AddRange(item.Receiver.Select(x => new MailboxAddress(x)));
message.From.AddRange(item.Sender.Select(x => new MailboxAddress(x)));
message.Subject = item.Subject;
message.Body = new TextPart(TextFormat.Html)
{
Text = item.Content
};
emailClient.Send(message);
}
}
catch(Exception e)
{
logger.LogError(e,ResilientLogger.ClassLibrary.Globals.LoggingGlobals.Error + "-" + e.Message);
}
emailClient.Disconnect(true);
}
但是,由于某种原因,我不断收到此错误:
MailKit.Net.Smtp.SmtpCommandException: Too many recipients
at MailKit.Net.Smtp.SmtpClient.OnRecipientNotAccepted(MimeMessage message, MailboxAddress mailbox, SmtpResponse response)
at MailKit.Net.Smtp.SmtpClient.ProcessRcptToResponse(MimeMessage message, MailboxAddress mailbox, SmtpResponse response)
at MailKit.Net.Smtp.SmtpClient.RcptToAsync(FormatOptions options, MimeMessage message, MailboxAddress mailbox, Boolean doAsync, CancellationToken cancellationToken)
at MailKit.Net.Smtp.SmtpClient.SendAsync(FormatOptions options, MimeMessage message, MailboxAddress sender, IList`1 recipients, Boolean doAsync, CancellationToken cancellationToken, ITransferProgress progress)
at MailKit.Net.Smtp.SmtpClient.SendAsync(FormatOptions options, MimeMessage message, MailboxAddress sender, IList`1 recipients, Boolean doAsync, CancellationToken cancellationToken, ITransferProgress progress)
at MailKit.Net.Smtp.SmtpClient.Send(FormatOptions options, MimeMessage message, CancellationToken cancellationToken, ITransferProgress progress)
at ManagementStudio.Connect.Email.Email.BulkSend(EmailConfigurationViewModel Configuration, List`1 EmailContents)
这是 IIS 错误还是我可以在代码中修复的问题?我正在使用 IIS8
【问题讨论】:
-
根据调用堆栈,是 SMTP 服务器响应您不应该设置这么多收件人。不足为奇,因为可能太多了。与 SMTP 服务器管理员交谈,了解您可能会更改的内容。
-
我的 SMTP 服务器在我的 IIS 上。我可以从那里改变什么?
-
我也在使用 Plesk Onyx。我检查了发送的电子邮件数量也没有限制。
标签: email asp.net-core iis .net-core mailkit