服务器忙,关闭传输通道。稍后在ASP.NET中发送邮件时再试一次

时间:2017-02-03 05:49:48

标签: c# asp.net email smtp smtpclient

我想发邮件。我有以下代码,它工作得很好。但是几天以来,我遇到了以下错误。

  

错误:服务不可用,关闭传输通道。服务器响应是:服务器忙,关闭传输通道。尝试   再来一次

代码:

try
{
    ServicePointManager.ServerCertificateValidationCallback = new RemoteCertificateValidationCallback(ValidateServerCertificate);
    using (MailMessage mm = new MailMessage("xxx@gmail.com", "yyy@gmail.com"))
    {
        mm.Subject = "Registration Successfully";
        mm.Body = "You are registered successfully. Welcome.";
        mm.IsBodyHtml = false;
        SmtpClient smtp = new SmtpClient();
        smtp.Host = "smtp.gmail.com";
        smtp.EnableSsl = true;
        NetworkCredential NetworkCred = new NetworkCredential("xxx@gmail.com", "password");
        smtp.UseDefaultCredentials = true;
        smtp.Credentials = NetworkCred;
        smtp.Port = 587;
        smtp.Send(mm);
    }
}
catch (Exception)
{
    throw;
}

我已阅读以下博客并尝试但没有工作。

1- Email alerts -while sending mail to multiple user 1 by 1 getting error as server busy

2- Send Bulk Email From Yahoo and Hotmail Using ASP.Net

1 个答案:

答案 0 :(得分:0)

有时候不要使用SMTP smtp.gmail.com来创建问题

最佳解决方案

        mm.Subject = "Registration Successfully";
        mm.Body = "You are registered successfully. Welcome.";
        mm.IsBodyHtml = false;
        SmtpClient smtp = new SmtpClient();
        smtp.Host = "domainname.com";
        smtp.EnableSsl = true;
        NetworkCredential NetworkCred = new NetworkCredential("demo@domainname.com", "password");
        smtp.UseDefaultCredentials = true;
        smtp.Credentials = NetworkCred;
        smtp.Port = 587;
        smtp.Send(mm);