Reputation: 427
I am getting junk characters when using php IMAP like
<b>Text in bold</b> getting converted to *Text in bold*
words like shouldn't are getting converted to shouldn=92t
the code I am using is
$inbox = imap_open('host', 'un', 'pw') or die('Cannot connect to Mail box: ' . print_r(imap_errors()));
$mails = imap_search($inbox,'UNSEEN');
if($mails) {
foreach($mails as $mail) {
echo $message = imap_fetchbody($inbox, $mail, 1);
echo "<br><br>";
}
}
imap_close($inbox);
can some one help me to find whats the issue is?
Upvotes: 0
Views: 296
Reputation: 925
You run into two different problems:
The text in bold is simply because the html in the mail is interpreted by the browser. To avoid this, you can escape the content with htmlentities() or htmlspecialchars()
"shouldn=92t" is a quoted-printable encoded string. This has to be decoded to be readable - can be done with quoted_printable_decode() or imap_qprint()
Upvotes: 2