使用PHP解码邮件正文时遇到问题。 我有2封UTF-8电子邮件,其结构完全相同。 对于一个我可以用iconv解码身体(" UTF-8"," Windows-1252",$ data) 对于另一个,这不起作用。 1)我不知道该使用什么而不是这个 2)如何识别动态区分这两种类型的电子邮件?
Object& update(const Object& obj)
当我在两个数据对象上使用imap_mime_header_decode时,我得到了这个:
stdClass Object
(
[type] => 1
[encoding] => 0
[ifsubtype] => 1
[subtype] => MIXED
[ifdescription] => 0
[ifid] => 0
[ifdisposition] => 0
[ifdparameters] => 0
[ifparameters] => 1
[parameters] => Array
(
[0] => stdClass Object
(
[attribute] => BOUNDARY
[value] => ----=_Part_8432_30170987.1457360103746
)
)
[parts] => Array
(
[0] => stdClass Object
(
[type] => 0
[encoding] => 4
[ifsubtype] => 1
[subtype] => PLAIN
[ifdescription] => 0
[ifid] => 0
[lines] => 50
[bytes] => 1811
[ifdisposition] => 0
[ifdparameters] => 0
[ifparameters] => 1
[parameters] => Array
(
[0] => stdClass Object
(
[attribute] => CHARSET
[value] => UTF-8
)
)
)
)
)
stdClass Object
(
[type] => 1
[encoding] => 0
[ifsubtype] => 1
[subtype] => MIXED
[ifdescription] => 0
[ifid] => 0
[ifdisposition] => 0
[ifdparameters] => 0
[ifparameters] => 1
[parameters] => Array
(
[0] => stdClass Object
(
[attribute] => BOUNDARY
[value] => ----=_Part_1135_19111967.1451925068339
)
)
[parts] => Array
(
[0] => stdClass Object
(
[type] => 0
[encoding] => 4
[ifsubtype] => 1
[subtype] => PLAIN
[ifdescription] => 0
[ifid] => 0
[lines] => 27
[bytes] => 490
[ifdisposition] => 0
[ifdparameters] => 0
[ifparameters] => 1
[parameters] => Array
(
[0] => stdClass Object
(
[attribute] => CHARSET
[value] => UTF-8
)
)
)
)
)
提前致谢, Stiti
答案 0 :(得分:1)
问题解决了: 我用过:
iconv("UTF-8", "Windows-1252//TRANSLIT//IGNORE", $data)
而不是:
iconv("UTF-8", "Windows-1252", $data)
现在效果很好。