【发布时间】:2019-01-18 19:01:58
【问题描述】:
我的代码开头是这样的:
$hostname = '{**HOST**}';
$username = '**USERNAME**';
$password = '**PASSWORD**';
$inbox = imap_open($hostname,$username,$password);
$emails = imap_search($inbox,'ALL');
if($emails)
{
$output = '';
rsort($emails);
foreach($emails as $email_number)
{
$header=imap_headerinfo($inbox,$email_number);
$from = $header->from[0]->mailbox . "@" . $header->from[0]->host;
$toaddress=$header->toaddress;
$replyto=$header->reply_to[0]->mailbox."@".$header->reply_to[0]->host;
$datetime=date("Y-m-d H:i:s",$header->udate);
$subject=imap_utf8($header->subject);
//remove the " from the $toaddress
$toaddress = str_replace('"','',$toaddress);
echo '<strong>To:</strong> '.$toaddress.'<br>';
echo '<strong>From:</strong> '.$from.'<br>';
echo '<strong>Subject:</strong> '.$subject.'<br>';
echo '<strong>date:</strong> '.$datetime.'<br>';
//get message body
$message = quoted_printable_decode(imap_fetchbody($inbox,$email_number,1.1));
if($message == '')
{
$message = quoted_printable_decode(imap_fetchbody($inbox,$email_number,1));
}
echo '<strong>msg:</strong> '.$message.'<br><br>';
}
}
$message 变量返回邮件内的内容,但如果此人回复我的电子邮件,之前发送的邮件也会在 $message 内。
这是我为$message 获得的输出示例:
Yes I would love it !
Le vendredi, janvier 18, 2019, 5:49 PM, test <test@xtestx.fr> a écrit :
Bonjour,
Merci de nous avoir contactés.
Aimez-vous faire cela ?
Si vous souhaitez d'autres informations, n'hésitez pas à répondre directement à ce mail.
Cordialement,
L'équipe.
我只想得到第一行“是的,我会喜欢它!”这实际上是我邮件的真正答案,因为下面所有的文字都是以前的邮件。
谢谢,
【问题讨论】:
-
据我所知,我认为引用实际上是已发送电子邮件的一部分。这几乎是不可能去掉的,因为引用风格可能会因发件人的邮件客户端而异
-
我不知道该怎么做,但也许所有的邮件客户端都有
在我想摆脱的第一行。类似于 preg 匹配的东西,它删除了第一行,然后是所有其他行 -
如果我刚刚向您发送了一条消息,其中包括许多其他详细信息,我还向您提供了我从 VCard 复制的联系人的邮件地址,会发生什么情况。看起来像这样:
Some text (even containing line breaks)... Here's the contact: (line break) "Some Name <some.name@example.com>" (line break) ... continuation of my message?没有引用。您仍然会使用这种方法将下面的部分作为引用