【发布时间】:2012-04-25 04:52:50
【问题描述】:
发送邮件时出现异常。 - 根据验证程序,远程证书无效。需要解决方案。 我的代码是:
public bool mailSender(string toMailId, string uniqueGuid)
{
try
{
SmtpClient smtpClient = new SmtpClient();
string linkForConfirm = "orderConfirmation.aspx?id=" + uniqueGuid;
string Subject = "Shiv Cart Grocery Shop Confirmation";
string body = " <div style='width:700px; margin:0 auto;'><div style='background-color:#800000; width:700px'>";
body += "</div><div><h2>Shiv Cart Grocery Shop</h2><h3 style='color:#0099FF; width:700px'> Click Below To Confirm Your Order</h3>";
body += "<a href='" + linkForConfirm+ "' id='a' ></a></div></div>";
MailAddress fromMailAddress = new MailAddress("mail@sumedhasoftech.com", "Shiv Cart");
MailAddress toMailAddress = new MailAddress(toMailId);
MailMessage mail = new MailMessage(fromMailAddress, toMailAddress);
mail.Subject = Subject;
mail.Body = body;
mail.IsBodyHtml = true;
smtpClient.Host = "smtp.gmail.com";
smtpClient.Credentials = new System.Net.NetworkCredential(WebConfigurationManager.AppSettings["MailSenderUserName"].ToString(), WebConfigurationManager.AppSettings["MailSenderPass"].ToString());
smtpClient.EnableSsl = true;
smtpClient.Send(mail);
return true;
}
catch (Exception)
{
return false;
}
}
【问题讨论】:
-
所以您只是想将 gmail.com 用作开放中继?
-
我猜你不见了:smtpClient.SmtpPort = 25;
-
请看这个可能对你有帮助的stackoverflow.com/questions/7982810/…
标签: asp.net c#-4.0 smtp html-email