使用imap_body仅获取电子邮件正文的某个部分

Rol*_*and 5 php

我有邮件,我需要通过PHP imap函数获取正文,然后将其存储在数据库中.这些邮件来自响应系统的发送.我使用此代码来获取电子邮件的正文

$bodyText = imap_fetchbody($mbox,$v,1.2);
if(!strlen($bodyText)>0){
     $bodyText = imap_fetchbody($mbox,$v,1);
}
Run Code Online (Sandbox Code Playgroud)

这完美但也包括原始邮件正文,有没有办法只获得回复.

整个电子邮件正文看起来像这样

**This is a test
-- 
Kind Regards,



-----Original Message-----
From: -------------
To:--------------------------
Subject: You have received a reply to your enquiry
New System
Date: Tue, 5 Jul 2011 16:24:28 +0200
Good day,
You have received the following reply to an enquiry you made 
-------------------------------------------------------------------------------------------------
test3     

--------------------------------------------------------------------------------------------------
To reply to this comment please click on the Reply To button and add the message you wish to send.**
Run Code Online (Sandbox Code Playgroud)

有没有办法只获取消息正文而没有使用IMAP函数或其他PHP函数的ORIGINAL MESSAGE?

mar*_*log 0

你尝试过吗

substr($wholeMessage, 0, strpos($wholeMessage, 0, "-----Original Message-----"));
Run Code Online (Sandbox Code Playgroud)

这会将消息从开头剪切到 ----Original Message--- 字符串开始的位置。脏,但可以满足您的需求

编辑:我假设你只有一个哑剧部分..如果你有几个,你可以只保存你需要的部分