简体   繁体   中英

How to decode subject line

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.

imap_mime_header_decode will work for you, ie

<?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

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

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

)

在字符串上使用imap_mime_header_decode()。

iconv_mime_decode() -解码MIME标头字段

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM