我同时使用 MimeKit 和 MailKit 通过 SMTP 服务器发送电子邮件。不过,时不时地,我的服务器会向我返回一个错误:
The SMTP server does not support the SMTPUTF8 extension
显然,我想阻止这些错误的发生。 MimeKit 中有没有办法在 SmtpClient、MimeMessage 或 MimeEntity 上禁用 SMTPUTF8 扩展?
我担心我问错了问题,或者在错误的地方寻求解决方案。如果有人可以对可能措辞不佳的问题进行澄清,请告诉我。
这是我发送的方式:
using (var client = new SmtpClient())
{
try
{
client.Connect("server", port);
// I've got reasons to remove this.
client.AuthenticationMechanisms.Remove("XOAUTH2");
client.Send(message);
client.Disconnect(true);
}
catch (Exception e)
{
// Pokemon Exception handling right here
// for the sake of showing what I'm doing.
}
}
您的收件人(或发件人)列表中的一个或多个电子邮件地址具有 unicode 地址(我不是说“显示名称”包含 unicode 字符,我的意思是“x@y.com "部分包含需要 SMTP 服务器支持 SMTPUTF8 扩展才能工作的 unicode 字符。
例如,您可能试图发送到诸如 日本语@日本语.jp
之类的电子邮件地址。请注意,传统上,只允许使用基于 ASCII 的电子邮件地址,不支持 SMTPUTF8 扩展的 SMTP 服务器无法处理非 ASCII 的电子邮件地址。
我是一名优秀的程序员,十分优秀!