我正在编写一个简单的 php 脚本来阅读电子邮件。
当我提取邮件正文时:
imap_body($mbox, $i);
我已经返回了这样的东西:
--0016e6db2b334d4d7904a883f4ec
Content-Type: text/plain; charset=ISO-8859-1
<The message arrived>
--0016e6db2b334d4d7904a883f4ec
Content-Type: text/html; charset=ISO-8859-1
<The message arrived>
--0016e6db2b334d4d7904a883f4ec--
我怎样才能只提取:? 我正在使用 php_imap。
谢谢。
最佳答案
如果您使用的是 IMAP,则可以使用 imap_body() 函数来读取正文。 PHP 有大量函数可以帮助您解析电子邮件。
http://www.php.net/manual/en/ref.imap.php
也检查一下 fetch_body() 函数。它将使您只获得 body 的一部分。
http://www.php.net/manual/en/function.imap-fetchbody.php
例如:
$message = imap_fetchbody($inbox,$email_number, 1.2);
关于php imap 读取正文消息,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/6766371/