使用 PHPMailer 发送 unicode 表情符号
Send unicode emoji with PHPMailer
我正在尝试通过 PHPMailer (5.2) 发送 unicode 表情符号,但我发送的电子邮件收到的是奇怪的字符而不是表情符号。
我目前正在发送 HTML 电子邮件,其中我只是 echo
一个包含一些 utf-8 表情符号的字符串并检查电子邮件源,该字符串似乎被正确打印。例如:
echo "";
产生:
=F0=9F=98=81
在电子邮件源代码中(应该没问题)。
事实证明,PHPMailer 在 HTML 电子邮件中默认使用 charset=iso-8859-1(在电子邮件 header 中你会发现 Content-Type: text/html; charset=iso-8859-1
而你应该使用 UTF -8: Content-Type: text/html; charset=UTF-8
.
您可以通过以下方式在 PHPMailer 中设置字符集:
$mail = new PHPMailer();
$mail->CharSet = 'UTF-8';
我需要使用稍微不同的:
$mail = new PHPMailer();
$mail->CharSet = 'utf-8';
我正在尝试通过 PHPMailer (5.2) 发送 unicode 表情符号,但我发送的电子邮件收到的是奇怪的字符而不是表情符号。
我目前正在发送 HTML 电子邮件,其中我只是 echo
一个包含一些 utf-8 表情符号的字符串并检查电子邮件源,该字符串似乎被正确打印。例如:
echo "";
产生:
=F0=9F=98=81
在电子邮件源代码中(应该没问题)。
事实证明,PHPMailer 在 HTML 电子邮件中默认使用 charset=iso-8859-1(在电子邮件 header 中你会发现 Content-Type: text/html; charset=iso-8859-1
而你应该使用 UTF -8: Content-Type: text/html; charset=UTF-8
.
您可以通过以下方式在 PHPMailer 中设置字符集:
$mail = new PHPMailer();
$mail->CharSet = 'UTF-8';
我需要使用稍微不同的:
$mail = new PHPMailer();
$mail->CharSet = 'utf-8';