中文字符编码适用于 hotmail,但不适用于 gmail 或 yahoo
我设法通过 IMAP 使用 hotmail 检索电子邮件的中文正文,但使用 gmail 或 yahoo 则不起作用。我不知道为什么:
$mbox = imap_open ("{localhost:995/pop3/ssl/novalidate-cert}", "info@*******.com", "********");
$email="[email protected]";
$num_mensaje = imap_search($mbox,"FROM $email");
$body = imap_fetchbody($mbox,$num_mensaje[0],"1");
$str = mb_convert_encoding($body,"UTF-8","big5,EUC-CN");
i managed to retrieve the email's body in chinese characters with hotmail via IMAP but with gmail or yahoo it doens't work. I don't know why:
$mbox = imap_open ("{localhost:995/pop3/ssl/novalidate-cert}", "info@*******.com", "********");
$email="[email protected]";
$num_mensaje = imap_search($mbox,"FROM $email");
$body = imap_fetchbody($mbox,$num_mensaje[0],"1");
$str = mb_convert_encoding($body,"UTF-8","big5,EUC-CN");
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
查看电子邮件中
Content-Transfer-Encoding
标头的内容。它会告诉您电子邮件正文的格式,这将决定您必须如何对其进行解码。您需要支持的传输编码包括:
7bit
、8bit
或binary
:这些格式不需要预处理。quoted-printable
:使用quoted_printable_decode
函数。base64
:使用base64_decode
。处理完传输编码后,您就可以应用
mb_convert_encoding
。Look at the contents of the
Content-Transfer-Encoding
header in the email message. It will tell you what format the body of the email is in, which will dictate how you must decode it.Transfer encodings you will need to support include:
7bit
,8bit
, orbinary
: These formats require no preprocessing.quoted-printable
: Use thequoted_printable_decode
function.base64
: Usebase64_decode
.Once you have handled the transfer encoding, THEN you can apply
mb_convert_encoding
.