从电子邮件PHP提取正文 [英] Extract body text from Email PHP

查看:144
本文介绍了从电子邮件PHP提取正文的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我目前正在使用imap流从收件箱中获取电子邮件.

I am currently using an imap stream to get emails from an inbox.

一切正常,除了我不确定如何获取电子邮件的正文和标题.如果执行imap_body($connection,$message),则在文本中包含与电子邮件附件相同的基数64.

Everything is working fine except I am unsure how to get the body text and title of the email. If I do imap_body($connection,$message) the base 64 equivalent of the email attachment is included in the text.

我目前正在使用此功能来获取附件.

I am currently using this function to get the attachments.

http://www.electrictoolbox.com/function- extract-email-attachments-php-imap/

推荐答案

使用PHP imap的功能不好玩.本页上的用户解释了获取电子邮件的不一致之处: http://php.net/manual/zh/function.imap-fetchbody.php#89002

Well php imap's function are not fun to work with. A user on this page explains the inconsistencies with getting emails: http://php.net/manual/en/function.imap-fetchbody.php#89002

使用他的有用信息,我创建了一种可靠的方式来获取电子邮件的正文.

Using his helpful information I created a reliably way to get an email's body text.

$bodyText = imap_fetchbody($connection,$emailnumber,1.2);
if(!strlen($bodyText)>0){
    $bodyText = imap_fetchbody($connection,$emailnumber,1);
}
$subject = imap_headerinfo($connection,$i);
$subject = $subject->subject;

echo $subject."\n".$bodyText;

这篇关于从电子邮件PHP提取正文的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆