我正在尝试使用以下方法获取电子邮件正文的特定部分:
$message = imap_fetchbody ($imap_stream,$n,1);
这适用于使用 Outlook、Hotmail、Yahoo 等发送的电子邮件。但是当我尝试获取从 Blackberry 或 Andriod 设备发送的电子邮件正文时,消息被编码和加扰,例如:
xmb250IHN0eWxlPSdjb2xvcjojRjk3MWIxMDNiMTEyYjExOGI0N2I1MWI1
虽然正文是编码的,但标题没问题。 如何解码从 Android 或黑莓设备发送的电子邮件的消息正文?
谢谢,
克里斯。
最佳答案
您应该能够运行 imap_fetchstructure获取编码值。如果该值等于 3,则需要通过 imap_base64 解码.
我以前使用过以下内容(不记得以前是否用发送的移动电子邮件测试过):
$structure = imap_fetchstructure($stream, $msgno);
$text = imap_fetchbody($stream, $msgno, $partnum);
if($structure->encoding == 3) {
$text = imap_base64($text);
} else if($structure->encoding == 4) {
$text = imap_qprint($text);
}
关于php - imap_fetchbody - 编码主体错误,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/5310817/