4

複数のアドレス (1000 人を超えるユーザー) に電子メールを送信し、次のコードを使用して、100 人未満のユーザーに電子メールを送信すると機能しますが、100 人を超えるユーザーの場合は機能せず、失敗した受信者に smtpfailedrecipientsexception をスローします! なぜ?有効なアドレスに電子メールを送信して、このエラーを回避するにはどうすればよいですか?

public void SendMailMessage (string[] to,string message,string subject) 
    {
        MailMessage mMailMessage = new MailMessage ();
        int lenght = to.GetLength(0);
        if (lenght > 1) {
            foreach (string email in to) {
                mMailMessage.Bcc.Add ( email );
            }
        }
        else {
            mMailMessage.To.Add ( to[0] );
        }

                mMailMessage.From = new MailAddress ("no-replay@mycompany.net");                  
                SmtpClient mSmtpClient = new SmtpClient ();
                mMailMessage.Body = message;
                mMailMessage.IsBodyHtml = true;
                mMailMessage.Priority = MailPriority.Normal;
                mMailMessage.Subject = subject;
                mSmtpClient.EnableSsl = true;                
                ServicePointManager.ServerCertificateValidationCallback = delegate(object s,X509Certificate certificate,X509Chain chain, SslPolicyErrors sslPolicyErrors) {return true;};                    
            try {  
                mSmtpClient.Send (mMailMessage);                
        }
        catch (SmtpFailedRecipientsException ex){
            for (int i = 0; i < ex.InnerExceptions.Length; i++)
            {
                SmtpStatusCode status = ex.InnerExceptions[i].StatusCode;
                if (status == SmtpStatusCode.MailboxBusy ||
                    status == SmtpStatusCode.MailboxUnavailable)
                {
                    Logger.Debug("Delivery failed - retrying in 5 seconds.");
                    System.Threading.Thread.Sleep(5000);
                    //client.Send(message);
                    mSmtpClient.Send (mMailMessage);

                }
                else
                {
                    Logger.Debug (string.Format ("Failed to deliver message to {0},{1}", ex.InnerExceptions[i].FailedRecipient, i));

                }

            }
        }
        catch (Exception ex)
        {
            Logger.Debug (string.Format("Exception caught in RetryIfBusy(): {0}", ex.ToString() ));
        }

    }
4

2 に答える 2

0

使用している SMTP サーバーが、100 人を超える受信者を持つメールを拒否しているようです。

あなたはできる:

  • メッセージを各受信者に直接送信する代わりに配布リストを使用する
  • 受信者が 100 人以下の複数のメッセージを送信する
  • 制限を変更するには、このサーバーの管理者に相談してください

ただし、何百人もの外部の受信者にメッセージを送信する場合、スパム フィルターがそれらをスパムとしてフラグ付けする可能性があることに注意してください。

于 2013-05-04T10:20:20.493 に答える