将非 ASCII 域转换为 SMTP 兼容域
当客户输入带有非 ASCII 字符(例如 äüö)的电子邮件地址时,我们的 SMTP 会拒绝处理它们。
所以我认为可能有一个解决方案可以自己处理这些域并将它们转换为 punyocode。
有没有使用 C# 的简单方法?
无论如何,这会起作用吗?
When customers enter email addresses with non-ascii chars like äüö our SMTP rejects to process them.
So I think might be there is a solution to handle those domains myself and convert them to punyocode.
Is there a simple way of doing so using c#?
Would this work anyway?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
您可以使用
Uri.DnsSafeHost
转换为 Punycode:在 app.config 中:
结果:
You can use
Uri.DnsSafeHost
to convert to Punycode:In app.config:
Result:
这种方法的问题是您将更改电子邮件地址。
电子邮件地址
[email protected]
和 < code>bevä[email protected] 不同 电子邮件地址,无论它们看起来多么相似。进行您建议的更改将破坏电子邮件 - 人们可能会收到邮件,但无法回复这些邮件。
不处理重音字符的 SMTP 服务器听起来就像恐龙一样。尽管这可能是众所周知的痛苦,但更换和/或升级可能是最好的解决方案。
您可能能够在 ServerFault 上获得更合适的帮助。
The problem with this approach is that you'll be changing the email addresses.
The email addresses
[email protected]
andbevä[email protected]
are different email addresses, however much they appear the same.Making the change you suggest will break email - people might receive the messages, but they won't be able to reply to them.
Your SMTP server that doesn't handle accented characters sounds like a dinosaur. Much as it might be a pain in the proverbial, replacement and/or upgrade is likely the best solution.
You'll likely be able to get more appropriate assistance over on ServerFault.
将电子邮件地址域名中的 Unicode 字符转换为 Punycode 可以解析正确的 DNS 记录,因此不会被 SMTP 拒绝。只需使用 System.Uri 即可完成,无需修改 app.config:
Converting Unicode characters in your email address' domain name to Punycode resolves the correct DNS records so it won't be rejected by your SMTP. It can be done simply using System.Uri without modifying app.config: