获取 IMAP 消息正文(PHP-IMAP 扩展)的字符集


Obtaining charset of IMAP message body (PHP-IMAP extension)

imap_headerinfoimap_fetchstructure都没有在结果中包含明显明显的Content-type标题[显然,我希望这在imap_headerinfo下找到]。我可以使用什么函数来获取原始标头,以便我可以解析该标头并相应地将消息正文转换为 UTF-8?

当然,在我提出问题之后,我在八分钟后就想通了。

解决方案是像这样在消息/部分组合中运行imap_fetchmime

$headers = imap_fetchmime($this->imapStream, $msgNumber, $partNumber);

这将包含每个部分的Content-type标头(如果可用)。