如何发送 UTF-8 电子邮件? [英] How to send UTF-8 email?

查看:42
本文介绍了如何发送 UTF-8 电子邮件?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

当我发送电子邮件时,电子邮件不显示英文以外的字符.它确实显示如下:

When I send out the email, the email does not show characters other than english. It does show like below:

ä½™ç"Ÿä»ä»

可能知道究竟是什么原因造成的?即使我尝试在脚本中添加 Content-type 和字符集,它仍然显示相同.

May know actually what cause this? Even I tried to added Content-type and charset in the script, it still show the same.

我使用了 Mail::Factory("mail");

推荐答案

您可以在邮件正文中添加标题Content-Type: text/html; charset=UTF-8".

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屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆