从电子邮件PHP提取正文 [英] Extract body text from Email 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屋!