2012-12-01 95 views
1

我想通过邮件服务器发送邮件(在fatcow中可用)。通过邮件服务器发送邮件Asp.net mvc4

Username: [email protected] 
SMTP Server:  smtp.hostname.com 
SMTP Port: 587 

我使用的follwing代码时,我用gmail服务器的代码工作正常,我收到的邮件来发送邮件,

if (ModelState.IsValid) 
{ 
    MailMessage message = new MailMessage(); 
    try 
     { 
       message.To.Add(new MailAddress("[email protected]")); 
       message.From = new MailAddress("[email protected]"); 
       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("[email protected]", "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) 
      { 
       ; 
      } 
     } 

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

我得到的错误,

the remote certificate is invalid according to the validation procedure 

还有什么事做,使其工作?

请帮帮忙,

谢谢

+1

作为第一检查安装我会建议检查你的SSL证书已正确安装在你的服务器上 – Iridio

+0

谢谢你..对...这是问题...我可以接受你的答案,如果你把它 – Kishore

回答

1

由于第一次检查,我会建议检查您的SSL证书被正确服务器

相关问题