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
還有什麼事做,使其工作?
請幫幫忙,
謝謝
作爲第一檢查安裝我會建議檢查你的SSL證書已正確安裝在你的服務器上 – Iridio
謝謝你..對...這是問題...我可以接受你的答案,如果你把它 – Kishore