在 PHP 中发送带有特殊字符的电子邮件
我有一个小型 Web 表单,单击提交按钮后,PHP 脚本将通过 HTML 邮件发送收据。该邮件包含特殊字符,即“å”、“ä”和“ö”。无论我尝试什么,我都无法让这些字符在任何地方都正确显示。在某些电子邮件客户端中,这些字符显示得很好,而在其他电子邮件客户端中,它们显示为问号。我尝试过以 UTF-8、ISO-8859-1、base-64 编码主题发送邮件,但我被严重难住了。
如何使用任意字符从 PHP 发送邮件,同时保证邮件在各处显示相同?
I have a small web form which will cause a PHP script to send a receipt upon clicking the submit button, by an HTML mail. This mail contains special characters, namely 'å', 'ä' and 'ö'. Whatever I try, I can't get these characters to display properly everywhere. In some email clients, these characters show up just fine, whereas in others they show up as question marks. I've tried sending the mail as UTF-8, as ISO-8859-1, base-64 encoding the subject, but I'm seriously stumped.
How do I send a mail from PHP using any characters while guaranteeing that the mail shows up the same everywhere?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
UTF-8 应该足够了,问题可能在于您如何发送电子邮件。我建议使用已经经过验证的库,例如 PHPMailer。
UTF-8 should be enough, the problem could be in how are you sending emails. I would suggest using an already proven library like PHPMailer.
尝试使用 phpMailer 或 pear mime_mail 类。
phpMailer 网站看起来很糟糕,但它实际上有一个很好且易于使用的邮件程序类。它会处理一切,您只需指定正确的编码即可。 (utf-8 或 ascii)
Try using phpMailer or the pear mime_mail classes.
The phpMailer website looks horrible but it actually has a nice and easy to use mailer class. It will take care of everything, you just have to specify the right encoding. (utf-8 or ascii)
除上述之外的另一个选择是 swift mailer - http://swiftmailer.org/
Another option asside from the above is swift mailer - http://swiftmailer.org/