使用imap_fetchbody检索html


Retrieve html using imap_fetchbody

我正在使用imap来检索电子邮件。它适用于纯文本。但在获取html时遇到问题,我使用了imap_fetchbody($connections,$email_number,1.2);,但它不起作用。它返回null。但如果我尝试imap_fetchbody($connections,$email_number,1.1);,它是纯文本的,我得到的是*,而不是html标记。

我非常感谢的任何帮助

根据PHP规范

 string imap_fetchbody ( resource $imap_stream , int $msg_number , string $section [, int $options = 0 ] )

请记住,数字应该是字符串,而不是整数,因此您的命令将是

 imap_fetchbody($connections,$email_number,"1.2");

希望这能解决您的问题

您正在使用的html可能缺少MIME类型。您可以尝试使用"<!DOCTYPE html> <html>"启动邮件内容。