发送国际化电子邮件

Th4*_*Guy 3 c# sendgrid

如何发送带有重音字母的电子邮件?例如, RFC 6532pep\xc3\xa9@lefrenchplace.com现在应该支持它

\n

pep\xc3\xa9@lefrenchplace.com如果我从 gmail 的网络界面发送电子邮件,则发送没有问题。

\n

我正在使用.NET 4.6.1C#SendGrid

\n

第一次尝试使用 SMTP:

\n
var smtp = new SmtpClient(Server)\n{\n    Credentials = new NetworkCredential(Username, ApiKey),\n    DeliveryFormat = SmtpDeliveryFormat.International\n};\n\nvar message = new MailMessage(From, To)\n{\n    Subject = Subjet,\n    Body = BodyPlainText\n};\n\nsmtp.Send(message);\n
Run Code Online (Sandbox Code Playgroud)\n

这会抛出一个SmtpException带有消息的The client or server is only configured for E-mail addresses with ASCII local-parts: pep\xc3\xa9@lefrenchplace.com.

\n

第二次尝试使用 SendGrid C# 库的 API V3

\n
var apiKey = Environment.GetEnvironmentVariable("NAME_OF_THE_ENVIRONMENT_VARIABLE_FOR_YOUR_SENDGRID_KEY");\nvar client = new SendGridClient(apiKey);\nvar from = new EmailAddress("test@example.com", "Example User");\nvar subject = "Sending with SendGrid is Fun";\nvar to = new EmailAddress("pep\xc3\xa9@lefrenchplace.com", "Example User");\nvar plainTextContent = "and easy to do anywhere, even with C#";\nvar htmlContent = "<strong>and easy to do anywhere, even with C#</strong>";\nvar msg = MailHelper.CreateSingleEmail(from, to, subject, plainTextContent, htmlContent);\nvar response = await client.SendEmailAsync(msg);\n
Run Code Online (Sandbox Code Playgroud)\n

我收到Accepted返回的状态代码。在 SendGrid 仪表板上,其原因显示为已删除且无效。

\n

Th4*_*Guy 5

2020年8月编辑

SendGrid 已关闭 Github 问题。任何想要符合标准的电子邮件提供商发送到国际化电子邮件地址的人都应该寻找其他地方。邮枪可以用


截至目前,SendGrid 根本不支持具有非 ASCII 本地部分的电子邮件地址。

他们告诉我,这已经在他们的关注范围内,但没有时间承诺实施。

Github问题