How to decode subject line

2019-08-08 23:41发布

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.

标签: php imap
5条回答
爷的心禁止访问
2楼-- · 2019-08-09 00:21

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

查看更多
劫难
3楼-- · 2019-08-09 00:22

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

查看更多
smile是对你的礼貌
4楼-- · 2019-08-09 00:22

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.
        )

)
查看更多
霸刀☆藐视天下
5楼-- · 2019-08-09 00:24

Use imap_mime_header_decode() on the string.

查看更多
叼着烟拽天下
6楼-- · 2019-08-09 00:33

iconv_mime_decode() - Decodes a MIME header field

查看更多
登录 后发表回答