如何发送UTF-8电子邮件? [英] How to send UTF-8 email?
问题描述
当我发送电子邮件时,电子邮件不会显示英文以外的字符。
它显示如下:
When I send out the email, the email does not show characters other than english. It does show like below:
ä½™çŸä»ä»
ä½™ç"Ÿä»ä»
可能知道是什么原因造成的?
即使我试图在脚本中添加Content-type和charset,它仍然显示相同。
May know actually what cause this? Even I tried to added Content-type and charset in the script, it still show the same.
我使用 Mail ::工厂(邮件);
推荐答案
您可以添加标题Content-Type:text /
You can add header "Content-Type: text/html; charset=UTF-8" to your message body.
$headers = "Content-Type: text/html; charset=UTF-8";
如果您使用本机 mail()
函数$ headers数组将是第四个参数
mail($ to,$ subject,$ message,$ headers)
If you use native mail()
function $headers array will be the 4th parameter
mail($to, $subject, $message, $headers)
如果您的用户PEAR Mail :: factory()代码将是:
If you user PEAR Mail::factory() code will be:
$smtp = Mail::factory('smtp', $params);
$mail = $smtp->send($to, $headers, $body);
这篇关于如何发送UTF-8电子邮件?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!