如何解决smtp客户端主机拒绝访问被拒绝的问题

时间:2016-10-03 09:43:22

标签: asp.net .net email smtp asp.net-mvc-5

我可以使用Gmail发送电子邮件,但现在我想使用我的域名发送电子邮件

以下是用于使用我的域

发送电子邮件的代码

但面临访问被拒绝的问题

SmtpClient client = new SmtpClient();
client.Host = "mail.xyz.com";
client.Port = 25;
client.EnableSsl = true;
client.UseDefaultCredentials = false;
client.Credentials = new System.Net.NetworkCredential("xxxx@xxxx.org", "xxxx");
                client.DeliveryMethod = SmtpDeliveryMethod.Network;
MailMessage maili = new MailMessage();
maili.Body = password;
maili.Subject = "Password Reset Confirmation";
maili.IsBodyHtml = true;
maili.From = new MailAddress("xxxx@xxxx.org");
maili.To.Add(email);
try
{
    ServicePointManager.ServerCertificateValidationCallback = delegate(object s, X509Certificate certificate, X509Chain chain, SslPolicyErrors sslPolicyErrors) 
    { 
        return true;         
    };
    client.Send(maili);
}
catch (Exception ex)
{
    throw ex;
}

提前致谢

0 个答案:

没有答案