开发者

imap_fetchbody - Encoded body error

开发者 https://www.devze.com 2023-02-16 18:20 出处:网络
I am trying to fetch a par开发者_StackOverflowticular section of an email body using: $message = imap_fetchbody ($imap_stream,$n,1);

I am trying to fetch a par开发者_StackOverflowticular section of an email body using:

$message = imap_fetchbody ($imap_stream,$n,1);

This works fine for emails sent using Outlook, Hotmail, Yahoo etc. But when I try and fetch the body of the an email sent from a Blackberry or Andriod device, the message is encoded and scrambled such as:

xmb250IHN0eWxlPSdjb2xvcjojRjk3MWIxMDNiMTEyYjExOGI0N2I1MWI1

Although the body is encoded, the header is fine. How do I decode the message body of en email sent from an Android or Blackberry device?

Thank you,

Chris.


You should be able to run imap_fetchstructure to get the encoded value. If that value equals 3 you need to decode via imap_base64.

I've used the following before (Can't remember if it was ever tested with sent mobile email before though):

$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);
}
0

精彩评论

暂无评论...
验证码 换一张
取 消