使用 UTF-8 编码网页中的瑞典语字符创建 Outlook 邮件

发布于 2024-10-14 11:02:55 字数 561 浏览 6 评论 0原文

我有一个数据库驱动的网站,用 php 编写,需要从数据创建电子邮件。所有数据和每个页面均以 UTF-8 编码,并包含大量瑞典语字符 åäö。我的 mailto-link 中有以下内容:

<a href="mailto:[email protected]?body=Hej!%0D%0AåäöÅÄÖ">Mailto-link</a>

并且电子邮件正文应该显示为

Hej!
åäöÅÄÖ

这至少可以使用 Internet Explorer 8 和 Firefox(尚未在 Chrome 或 Safari 中测试)与 Outlook 2007 一起使用。但是,在 Internet Explorer 7 或更早版本中,åäö 显示为奇怪的字符。我们的许多客户都被 IE 6 和 7 困住了。对于如何实现这一点有什么建议吗?

I've got a database-driven website, written in php, which needs to create e-mails from the data. All data and every page is encoded in UTF-8, and contains plenty of the Swedish characters åäö. I've got the following in my mailto-link:

<a href="mailto:[email protected]?body=Hej!%0D%0AåäöÅÄÖ">Mailto-link</a>

and the e-mail body is supposed to come out as

Hej!
åäöÅÄÖ

This works using Internet Explorer 8 and Firefox at least (haven't tested in Chrome or Safari) with Outlook 2007. However, in Internet Explorer 7 or earlier the åäö comes out as weird characters. Many of our clients are stuck with IE 6 and 7. Any suggestions on how to make this work?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(3

渔村楼浪 2024-10-21 11:02:55

如果您遇到这样的问题,只需将导致问题的内容放入此 Javascript 警报语句中,然后将其粘贴到 Opera 或 Firefox 等不错的浏览器的地址栏中。

javascript:alert(escape("problem-string-here"));

例如,如果执行,

javascript:alert(escape("åäöÅÄÖ"));

您将得到 %E5%E4%F6%C5%C4%D6。您可以复制警报语句显示的文本,然后在 mailto 链接中使用它:

mailto: [电子邮件受保护]?body=嘿!%0a%E5%E4%F6%C5%C4%D6

If you ever face a problem like this just put the content that is causing the trouble in this Javascript alert statement and paste it in address bar of a decent browser such as Opera or Firefox.

javascript:alert(escape("problem-string-here"));

For example, if you execute

javascript:alert(escape("åäöÅÄÖ"));

you will get %E5%E4%F6%C5%C4%D6. You can copy the text displayed by the alert statement and then use it in your mailto link:

mailto:[email protected]?body=Hey!%0a%E5%E4%F6%C5%C4%D6

作妖 2024-10-21 11:02:55

我认为,如果您尝试使用“mailto:”链接来解决问题,那么浪费的可能的浏览器/电子邮件客户端组合会给您带来无尽的悲伤。理论上 url 编码应该可以工作,但是当我过去尝试过这个时,我发现从 PHP 发送电子邮件更容易。

但这带来了其他挑战,例如确保垃圾邮件发送者无法将您的服务器用作电子邮件网关(例如,在表单中使用联系人 ID 号码而不是电子邮件地址)。验证码和速率限制可能也是一个好主意。

I think the wast number of possible browser/email client combinations out there is going to give you an endless amount of grief if you try to solve it with a "mailto:" link. Theoretically url-encoding should work, but when I've dabbled with this in the past I figured out it was easier to just send email from PHP in stead.

That brings other challenges though, such as making sure you don't make it possible for spammers to use your server as an email gateway (eg. use contact ID numbers in stead of email addresses in the form). Captcha and rate limiting is probably a good idea as well.

臻嫒无言 2024-10-21 11:02:55

URL 编码 字符(不仅仅是换行符)可能 帮助。在 PHP 中,正确的函数是 urlencode()

URL encoding the characters as well (not just the line breaks) might help. In PHP, the right function would be urlencode().

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文