Question

I received an email whose subject line is Last Day Today☛ An Additional 32% Off Your Favourite Brands, but when I looked into it's header subject line looks like -

Subject: =?utf-8?Q?Last=20Day=20Today=E2=98=9B=20An=20Additional=2032%=20Off=20Your=20?=
=?utf-8?Q?Favourite=20Brands.?=

If I fetch out value of subject using imap_headerinfo() then how could I decode this value.

Was it helpful?

Solution

You can also try mb_decode_mimeheader(); This might work for you.

OTHER TIPS

imap_mime_header_decode will work for you, i.e.

<?php
$text = "=?utf-8?Q?Last=20Day=20Today=E2=98=9B=20An=20Additional=2032%=20Off=20Your=20?=
=?utf-8?Q?Favourite=20Brands.?=";

$elements = imap_mime_header_decode($text);
var_dump($elements); //will print array values for you

here is more detail PHP IMAP Header decode

Try imap_mime_header_decode:

<?php

print_r(imap_mime_header_decode('=?utf-8?Q?Last=20Day=20Today=E2=98=9B=20An=20Additional=2032%=20Off=20Your=20?=
=?utf-8?Q?Favourite=20Brands.?='));

Output:

Array
(
    [0] => stdClass Object
        (
            [charset] => utf-8
            [text] => Last Day Today☛ An Additional 32% Off Your 
        )

    [1] => stdClass Object
        (
            [charset] => utf-8
            [text] => Favourite Brands.
        )

)

Use imap_mime_header_decode() on the string.

iconv_mime_decode() - Decodes a MIME header field

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top