0

我在 SendGrid 的帮助下发送电子邮件。下面是代码。

            var client = new SendGridClient(apiKey);
            EmailAddress from = new 
            EmailAddress("a.b@mycompany.com", "Ashutosh");
            List<EmailAddress> tos = new List<EmailAddress>
            {
                new EmailAddress("a.b@mycompany.com", 
                                 "Ashutosh"),
            };

            StringBuilder emailBodyContent = new StringBuilder();
            var textContent = "Hi, ";
            emailBodyContent.AppendFormat("<p>Hi, </p>");
            emailBodyContent.AppendFormat("<p>This is your email.</p>");




            var emailSubject = "Attachment names are not unique";

            msg = MailHelper.CreateSingleEmailToMultipleRecipients(from, 
            tos, emailSubject, textContent, emailBodyContent.ToString());
            var response = await client.SendEmailAsync(msg);

现在我想发送安全电子邮件。我通过以下链接

https://sendgrid.com/docs/Classroom/Basics/Email_Infrastructure/smtp_ports.html

但我不明白如何通过代码设置端口 587 或为发送网格启用安全电子邮件设置。

4

2 回答 2

2

如果您使用的是SendGrid v3 API ,则根本不必担心 SMTP。您只需调用 Web API 即可发送电子邮件。所有调用都是 HTTPS。

查看源代码,注意https

private void InitiateClient(string apiKey, string host, ...)
{
    ...
    var baseAddress = host ?? "https://api.sendgrid.com";
    ...
于 2017-07-10T11:51:41.247 回答
1

我还发现下面的 url 说默认情况下 SendGrid 使用 TLS。

https://sendgrid.com/blog/sendgrid-and-the-future-of-email-security/

于 2017-07-10T12:09:28.190 回答