c# - 如何使用 SMTP 发送安全电子邮件

标签 c# asp.net encryption smtp security

我目前正在使用 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/

相关文章:

c# - 更改默认的工具栏按钮悬停模板

C# 日历约会捕获

javascript - 如何仅在angularjs中将小数限制为2位

security - 我应该对密码施加最大长度限制吗?

python - Pycrypto - 在 Linux 上加密/在 Windows 上解密

c# - 在 Windows 窗体中将数据异步加载到 DataTable

C#:为什么 ShowDialog().ToString() 不返回预期的字符串?

asp.net 文本框添加BehaviorID

javascript - jQuery SignalR 客户端 .off() 函数仅删除最后注册的回调

SSL channel 被加密或数据