【问题标题】:Sending Mail via Mail Server Asp.net mvc4通过邮件服务器 Asp.net mvc4 发送邮件
【发布时间】:2012-11-19 09:11:46
【问题描述】:

我正在尝试通过邮件服务器发送邮件(在 fatcow 中可用)。

Username:    info@efernssolutions.com
SMTP Server:     smtp.hostname.com
SMTP Port:   587

我使用以下代码发送邮件,

 if (ModelState.IsValid)
 {
   MailMessage message = new MailMessage();
     try
        {
                message.To.Add(new MailAddress("kishore.eferns@gmail.com"));
                message.From = new MailAddress("info@efernssolutions.com");
                message.Subject = "Test mail";
                message.Body = "this is the mail sended through my c#.net program";
                message.BodyEncoding = System.Text.Encoding.UTF8;
                message.SubjectEncoding = System.Text.Encoding.UTF8;

                SmtpClient client = new SmtpClient();
                client.Port = 587; 
                client.Host = "smtp.hostname.com";
                System.Net.NetworkCredential nc = new System.Net.NetworkCredential("info@efernssolutions.com", "password");// is u are using Gmail
                client.EnableSsl = true;
                client.UseDefaultCredentials = false;
                client.Credentials = nc;
                ServicePointManager.ServerCertificateValidationCallback = new RemoteCertificateValidationCallback(ValidateServerCertificate);
                client.Send(message);
            }
            catch (Exception ex)
            {
                ;
            }
        }

当我使用 gmail 服务器时,代码工作正常,我收到了邮件。

但它不适用于我的电子邮件服务器。

我得到了错误,

the remote certificate is invalid according to the validation procedure

还有什么可以让它发挥作用的吗?

请帮忙,

谢谢

【问题讨论】:

  • 作为第一个检查,我建议检查您的 SSL 证书是否正确安装在您的服务器上
  • 谢谢你..你是对的......这就是问题......如果你说的话我可以接受你的回答

标签: asp.net email asp.net-mvc-4


【解决方案1】:

作为第一个检查,我建议检查您的 SSL 证书是否正确安装在您的服务器上

【讨论】:

    猜你喜欢
    • 2018-10-17
    • 1970-01-01
    • 1970-01-01
    • 2011-02-07
    • 1970-01-01
    • 1970-01-01
    • 2018-01-05
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多