我有以下操作方法从我的asp.net mvc-5 Web应用程序发送电子邮件,作为联系我们部分的一部分: -
[HttpPost]
public ActionResult Contact(Contact c)
{
//
if (ModelState.IsValid)
{
MailMessage mail = new MailMessage();
mail.From = new MailAddress("****.com");
mail.To.Add(new MailAddress("****.com"));
mail.Subject = "New Feedback Web Site";
mail.IsBodyHtml = true;
System.Text.StringBuilder mailBody = new System.Text.StringBuilder();
mailBody.AppendLine("<b>Dear Sirs, </b><br/><br/>");
mailBody.AppendLine(
"New Feedback hae been submitted , with the following details :- <br/><p>" +
"- Name : <span style='color:#78a22f'>" + c.Name + "</span><br/>" +
"- Email : <span style='color:#78a22f'>" + c.Email + "</span><br/>" +
"- Telephone : <span style='color:#78a22f'>" + c.Telephone + "</span><br/>"
+
"- Message : <span style='color:#78a22f'> " + c.Message + " </span><br/><br/></p>" +
"<span style='font-weight:bold'>Regards</span> <br/> <span style='font-weight:bold'></span>"
);
// mailBody.AppendLine("<br/><br/><div style='color:#f99406;font-weight:bold'>scanning Management </div> <br/> <div style='color:#f99406;font-weight:bold'>Best Regards</div></span>");
//System.Environment.NewLine
mail.Body = mailBody.ToString();
// Create a new Smpt Client using Google's servers
var smtpClient = new SmtpClient();
smtpClient.DeliveryMethod = SmtpDeliveryMethod.Network;
smtpClient.EnableSsl = true;
smtpClient.Host = "smtp.gmail.com";
smtpClient.Port = 587;
// This is the critical part, you must enable SSL
smtpClient.Credentials = new System.Net.NetworkCredential
("**@***.com", "******"); // ***use valid credentials***
//smtp.Port = ;
//Or your Smtp Email ID and Password
//smtp.EnableSsl = true;
smtpClient.Send(mail);
现在我的网站部署在http而不是https下,但在SMTPClient()
我定义为使用Enable.ssl =true
并且我使用的是端口587.所以我的问题是电子邮件会以安全的方式发送吗?我应该使用https而不是http联系我们吗?