Imap_fetchbody - Coded body error

I am trying to get a specific email body section using:

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

This is great for emails sent using Outlook, Hotmail, Yahoo, etc. But when I try to get the body of an email sent from a Blackberry or Andriod device, the message is encoded and scrambled, for example:

 xmb250IHN0eWxlPSdjb2xvcjojRjk3MWIxMDNiMTEyYjExOGI0N2I1MWI1 

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

Thanks,

Chris.

+4
source share
1 answer

You can run imap_fetchstructure to get the encoded value. If this value is 3, you need to decode via imap_base64 .

I used the following earlier (I don't remember if it had ever been verified with sent mobile email before):

 $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)); } 
+6
source

Source: https://habr.com/ru/post/1343755/


All Articles