This is an old question, but I recently ran into this problem while parsing emails. When printing header information using the imap_header_info function , the following array was shown:
stdClass Object
(
[subject] => =?Windows-1252?Q?field_name_-_need___`at_risk=92____into_t?= =?Windows-1252?Q?he_label_(_some_content_to_)_?=
)
However, the original object was " field name - you need to take a chance in the label (some content) "
To fix this problem, the imap_mime_header_decode function should be used in a loop to generate the correct text:
$header = imap_headerinfo($email_obj, $email_ref_number, 0);
$elements = imap_mime_header_decode($header->subject);
$email_subject = '';
if ( ! empty($elements)) {
foreach ($elements AS $e_part) {
if (isset($e_part->text)) {
$email_subject .= $e_part->text;
}
}
}
echo $email_subject;
source
share