I'm creating a small, web based, mail client in PHP and noticed that a number of email Subjects and Contents appear as follows:
=?ISO-8859-1?Q?Everything_for_=A35_-_Box_Sets,_Games_?= =?ISO-8859-1?Q?and_CD_Soundtracks...hurry,_ends_soon?=
=?utf-8?B?UGxheS5jb206IE9uZSBEYXkgT25seSDigJMgT3V0IG9mIHRoaXMgV29ybGQgRGVhbHMh?=
=?windows-1252?Q?Jon,_delivery_on_us_&_earn_=A35_credit_or_50_prints?=
Does anyone have any ideas for decoding them so they display correctly?
This is MIME-encoded string mainly used for headers. You can find lots of libraries that can handle this. For example, get PEAR::mail and use this function,
This is an RFC 2047 encoded-word. It is decoded by the
mb_decode_mimeheader
function.This is an old question but recently I came across this issue while parsing the emails. When printing the header info using function imap_header_info, the following array was shown:
However, the original subject was "field name - need at risk into the label (some content to)"
In order to fix this issue, the function imap_mime_header_decode has to be used within a loop to generate the correct text: