PHP Mail - UTF 8 汉字编码问题

发布于 2024-11-02 10:28:30 字数 612 浏览 0 评论 0原文

我有一个发送电子邮件的 PHP 邮件脚本,我需要用中文发送一些电子邮件。我有以下代码:

$email_header = "From: $from\n";
$email_header .= "X-Priority: 1\n"; //1 UrgentMessage, 3 Normal
$email_header .= "Return-Path: <$return>\n";
$email_header .= "Content-type: text/html; charset=utf-8\n";
mail($row["email"], '=?UTF-8?B?'.base64_encode($subject).'?=', $email_body, $email_header);

我遇到的问题是电子邮件的主题和正文 - 发送方式如下:

Subject: ???????????

Body: ???????????????

?????

??????????????????????????????????????????????????

????? 

显然不是中文!如果有人能指出我正确的方向,那就太好了。

预先感谢,

荷马。

I have a PHP Mail script that sends out emails and I need to send some out in Chinese. I have the following code:

$email_header = "From: $from\n";
$email_header .= "X-Priority: 1\n"; //1 UrgentMessage, 3 Normal
$email_header .= "Return-Path: <$return>\n";
$email_header .= "Content-type: text/html; charset=utf-8\n";
mail($row["email"], '=?UTF-8?B?'.base64_encode($subject).'?=', $email_body, $email_header);

The issue I have is with both the Subject of the Email and the body - it is sending as follows:

Subject: ???????????

Body: ???????????????

?????

??????????????????????????????????????????????????

????? 

Clearly not Chinese!!! If anyone can point me in the right direction, that would be great.

Thanks in advance,

Homer.

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

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

发布评论

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

评论(1

帝王念 2024-11-09 10:28:30

看起来像是数据库连接问题而不是邮件程序问题。也许忘记了设置名称 utf-8...?

Looks like a database connection issue rather than a mailer issue. Perhaps forgot to do a set names utf-8...?

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