从php中获取gmail imap的Message-ID值 [英] getting the value of Message-ID from gmail imap with php
问题描述
我使用标准的imap函数来抓取邮件,我需要保留
的Message-ID(和References和In-Reply-To)的轨迹来构建
线程。
我通过smtp回复邮件,保留旧主题,但是在我的Web界面中并未将它们与其他人分组。如果我添加一个In-Reply-To头文件 - 一切正常。
I use standard imap functions to grab mails, I need to keep track of the Message-ID (and References and In-Reply-To) to build threads. I reply to messages through the smtp, keeping the old subject, but in my web interface is not group them with others. If I add a In-Reply-To header - everything is OK.
问题是我无法获取Message-ID,References,In-Reply - (但在网络界面,他们是存在的)。
我试过不同的函数(imap_headerinfo,imap_fetchheader,imap_fetch_overview),但所有这些值都是空的。
The problem is that I can't get values of Message-ID, References, In-Reply-To (but in web interface they are present). I've tried different functions (imap_headerinfo, imap_fetchheader, imap_fetch_overview), but all of this values are empty.
请帮忙!
推荐答案
消息ID的格式如下:
The message ID is in a format like:
<OTJMCQtXnqgMaP1rLJi-cD9IvuH+xuVndE-DoWAZB0cbdffqHdw@mail.gmail.com>
它被浏览器解析为HTML标记,下面的代码将输出一个消息ID可以通过浏览器显示的方式:
which is parsed by the browser as an HTML tag, the following code will output a message ID in a way that can be displayed by the browser:
$this->mbox = imap_open('{imap.gmail.com:993/imap/ssl}', $email, $password);
$headers = imap_header($this->mbox, 1);
echo htmlentities($headers->message_id);
或者,如果您绝对必须使用print_r:
Or if you absolutely must use print_r:
$this->mbox = imap_open('{imap.gmail.com:993/imap/ssl}', $email, $password);
ob_start();
print_r(imap_header($this->mbox, 1));
print_r(imap_fetch_overview($this->mbox, 1));
print_r(imap_fetchheader($this->mbox, 1));
echo htmlentities(ob_get_clean());
这篇关于从php中获取gmail imap的Message-ID值的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!