我目前正在使用 Google Apps 发送 SMTP 电子邮件。如果我的项目部署了一些我将要发送的信息将是保密的,我想确保传输是安全的。任何人都可以让我知道我需要做什么来确保我通过 google apps smtp 服务器使用 smtp 发送安全的电子邮件吗? smtp.google.com。
非常感谢任何帮助。
据我所知,我需要强制使用 Https 并拥有 SSL 证书才能执行此操作。不知道这是不是真的?
最佳答案
您可以使用“smtp.EnableSsl = true”来启用 SSL 以确保安全。
MailMessage mail = new MailMessage();
mail.To.Add("" + to + "");
mail.From = new MailAddress("" + from + "");
mail.Subject = "Email using Gmail";
string Body = "Hi, this mail is to test sending mail" +
"";
mail.Body = Body;
mail.IsBodyHtml = true;
Attachment at = new Attachment(Server.MapPath("~/ExcelFile/TestCSV.csv"));
mail.Attachments.Add(at);
mail.Priority = MailPriority.High;
SmtpClient smtp = new SmtpClient();
smtp.Host = "smtp.gmail.com"; //Or Your SMTP Server Address
smtp.Credentials = new System.Net.NetworkCredential(""+ username +"", ""+ password +"");
smtp.EnableSsl = true;
smtp.Port = 587;
smtp.Send(mail);
关于c# - 如何使用 SMTP 发送安全电子邮件,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/11681026/