2012-01-18 75 views
2

目前我正在制作一个系统来跟踪我的电子邮件,但我不希望显示原始邮件。获取IMAP邮件的回复

有没有办法让IMAP只返回回复?不是全部(当你按回复任何电子邮件客户端的电子邮件时,它将原始电子邮件添加到底部)。或者通过PHP本身做到这一点?我现在有

$msg = nl2br($msg); 
     $msgs2 = explode("<br />", $msg); 
     //pre($msgs2); 

     foreach($msgs2 as $msg) { 
      if(strpos($msg, '> ') === false) $message .= "<br>".$msg; 
     } 
     return $message; 

但是,如果你看一下原始的Gmail答复,它有东西ssuch作为HTML版本等。

> --f46d0442889037c1fc04b6c20955 Content-Type: text/plain; charset=ISO-8859-1 
> 
> fghjfghjfgh test test eteststs 
> 
> On Tue, Jan 17, 2012 at 11:35 PM, mm < 
> mg.com> wrote: 
> 
> > 
> > On 17 Jan 2012, at 05:56, mom wrote: 
> > 
> > > Another email hahahahqa! 
> > > On 17 Jan 2012, at 05:47, mcom wrote: 
> > > 
> > >> Test message, higgins is very fat 
> > >> 
> > >> 
> > >> 
> > >> 
> > >> 
> > >> Please do not edit below 
> > >> ************************* 
> > >> S 
> > > 
> > 
> > 
> 
> 
> -- 
> 
> --f46d0442889037c1fc04b6c20955 Content-Type: text/html; charset=ISO-8859-1 Content-Transfer-Encoding: quoted-printable 
> 
> fghjfghjfgh test test eteststs<br><br><div class=3D"gmail_quote">On 
> Tue, Ja= n 17, 2012 at 11:35 PM, <a 
> href=3D"mailto:maom">mm</a> 
> <span dir=3D"ltr">&lt;<a href=3D"mailto:mn= 
> g.com">ma</a>&gt;</span> wrote:<br> <blockquote 
> class=3D"gmail_quote" style=3D"margin:0 0 0 .8ex;border-left:1p= x 
> #ccc solid;padding-left:1ex"><br> On 17 Jan 2012, at 05:56, <a href=3D"mailto:.com">mag.com</a> 
> wrote:<br> <br> &gt; Another email hahahahqa!<br> &gt; On 17 Jan 2012, 
> at 05:47, <a href=3D"mailto:.com">ma= 
> na.com</a> wrote:<br> &gt;<br> &gt;&gt; Test message, 
> higgins is very fat<br> &gt;&gt;<br> &gt;&gt;<br> &gt;&gt;<br> 
> &gt;&gt;<br> &gt;&gt;<br> &gt;&gt; Please do not edit below<br> 
> &gt;&gt; *************************<br> &gt;&gt; S<br> &gt;<br> <br> </blockquote></div><br><br 
> clear=3D"all"><div><br></div>-- <br>Regards,<div= 
> >,</div><div>=A0</div><br> 
> 
> --f46d0442889037c1fc04b6c20955-- 

但是那只是Gmail中,也有很多其他的电子邮件客户端,并等等,任何人都可以帮忙?

回答

2

在电子邮件中没有引用通用标准格式 - 包括GMail在内的所有电子邮件客户端都有自己的方式来发现构成“回复”的内容。因此,IMAP无法仅提取邮件中的“回复”。

1

它没有IMAP方法,所以你只需要自己过滤它。但是,引用字符有时会有所不同,甚至主要的邮件客户端(如Gmail和Hotmail,本地程序(如Outlook和Thunderbird)也会在一段时间内出错)。你可以过滤从>开始的行,但要注意这不是100%正确的。