有用的IMAP标头信息未显示 [英] Useful IMAP header information not showing up

查看:66
本文介绍了有用的IMAP标头信息未显示的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在使用标准的IMAP函数来获取PHP中的电子邮件.我需要跟踪每个消息的Message-ID(以及ReferencesIn-Reply-To)以建立线程.部署此系统后,我希望用户能够在其邮件客户端中回复消息,以将消息添加到线程中,但是在我的Web界面中,回复无法附加到原始帖子中,因为我没有任何电子邮件标头中的In-Reply-To ID.我会使用In-Reply-To ID将他们的回复附加到我发送给他们的新帖子的通知中,但是我不能,因为我无法获得ID.如果我有In-Reply-To标头,则可以对消息进行分组,因为有一个ID线程将它们连接起来.

I'm using standard IMAP functions to get emails in PHP. I need to keep track of the Message-ID (and References and In-Reply-To) for each message to build threads. Once this system gets deployed, I want users to be able to reply to messages in their mail client to add a message to a thread, but in my web interface, replies can't be attached to the original post because I don't have an In-Reply-To ID from any email headers. I would use In-Reply-To ID to attach their reply to the notification that I sent to them of a new post, but I can't because I can't get the IDs. If I had an In-Reply-To header, messages could be grouped, as there is a thread of IDs connecting them.

此外,如果提交或类似的内容有错误,我希望能够回复用户发送到服务器电子邮件地址的任何消息,在这种情况下,我需要他们的Message-ID邮件,这样我就可以确定我发送回信的邮件的In-Reply-To ID.

Also, I want to be able to reply to any message that the user sends to the server email address if there was an error with their submission or anything like that, in which case I'll need the Message-ID of their message so that I can make that the In-Reply-To ID of the message that I send in reply.

即使它们确实具有值,我也无法获得Message-ID的值,也无法获得In-Reply-To的值. (转到Gmail中的任何邮件,单击回复"按钮旁边的下拉菜单,单击显示原始邮件",您会发现,当我调用IMAP函数时,我所缺少的所有标头信息都已经存在,例如尽管Gmail不想将该信息提供给IMAP服务器.)

I can't get values for Message-ID, nor In-Reply-To even though they actually have values. (Go to any message in Gmail, click the dropdown menu next to the reply button, hit "show original", and you will see that all of the header information that is missing for me when I call the IMAP functions is actually there, as though Gmail doesn't want to give out that information to IMAP servers.)

我尝试了各种各样的调用,这些调用据说可以获取标头信息(imap_headerinfoimap_fetchheaderimap_fetch_overview),但是它们都为我不需要的标头信息返回了稀疏值数组.执行后

I've tried a variety of calls that supposedly get the header information (imap_headerinfo, imap_fetchheader, imap_fetch_overview), but they all return the array of sparse values for the header info that I don't need. After executing

$this->mbox = imap_open('{imap.gmail.com:993/imap/ssl}', $email, $password);

通过以下任何调用,我只能从标题中获取一些有用的值:

I can get only a few useful values out of the header with any of these calls:

imap_header($this->getImapStream(), "1");
imap_fetch_overview($this->getImapStream(), "1");
imap_fetchheader($this->getImapStream(), "1");

我可以看到SubjectToReply-To和其他标头值之类的东西,它们都是准确的,但是Message-IDReferencesIn-Reply-To和其他有价值的标头信息是很大程度上不存在(相反,表示它们的数组值在每种情况下都是空的.)

I can see stuff like Subject, To, Reply-To, and other header values, and they are all accurate, but Message-ID, References, In-Reply-To, and other valuable header information is largely absent (rather, the array values that represent them are empty in every case).

我几乎可以保证问题不在于代码本身,因为我可以在标头中看到一些值,并且可以成功地检索消息的主体;就像Google正在过滤我可以看到的标题信息一样.

I can almost guarantee that the problem isn't with the code itself, as I can see some values in the headers, and I can successfully retrieve the bodies of messages; it's simply as though Google is filtering what header information I can see.

您可能会注意到,我遇到的问题与

You may notice that I have the exact same question as on this page, but it was suggested that I make my own question, so that's what I've done.

如果有人可以给我一种从服务器回复邮件的方法,而又无需检索我要回复的邮件的Message-ID,那将同样棒.

If somebody can give me a way to reply to messages from my server without needing to retrieve the Message-ID of the message to which I'm replying, that'd be equally awesome.

我从很大的收件箱中的每封邮件中列出了Message-ID,据我所见,大约有40%的ID实际显示出来.如果我再次运行相同的测试,则相同的消息将保留其Message-ID.我正在显示Message-ID的消息中搜索模式,但是有很强的证据表明消息类型中没有模式.

I listed the Message-ID from every message in my very large inbox and, from what I can see, about 40% of the IDs actually show up. If I run the same test again, the same messages retain their Message-IDs. I am searching for a pattern among the messages that show the Message-ID but there is very strong evidence for a non-pattern among the types of messages.

实际上,每条消息都有一个Message-ID(即使对于ID不在IMAP查询中显示的消息,我也对此进行了验证),但是IMAP函数仅显示了某些消息的ID. /p>

Every message, in reality, has a Message-ID (and I have verified this for even the messages whose IDs don't show up with IMAP queries), but IMAP functions only reveal the ID of some of the messages.

推荐答案

事实证明,标题实际上并没有丢失.当我print_r打这些电话时:

Turns out that the headers weren't in fact missing. When I was print_ring these calls:

imap_header($this->getImapStream(), "1");
imap_fetch_overview($this->getImapStream(), "1");
imap_fetchheader($this->getImapStream(), "1");

我忽略了用htmlspecialchars在其上生成转义字符,这很重要,因为Message-ID看起来有点像<lotsOfArbitraryNumbersAndLetters@domain.com>或接近它的东西,而我的浏览器认为嘿,那是一个奇怪的标记,但是我会把它当成一个!"

I neglected to generate escape characters on them with htmlspecialchars, which matters because Message-IDs look a little something like <lotsOfArbitraryNumbersAndLetters@domain.com> or something close to it, and my browser thought "Hey, that's an odd tag, but I'll treat it like one!"

这篇关于有用的IMAP标头信息未显示的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆