阅读电子邮件imap php [英] Read email imap php

查看:222
本文介绍了阅读电子邮件imap php的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我使用PHP - Codeigniter(Peeker Library)作为后端,并使用IMAP从多个电子邮件地址获取电子邮件。

I am using PHP - Codeigniter (Peeker Library) as back-end and using IMAP to fetch emails from multiple email addresses.

我们有一些复杂的搜索条件查询imap文件夹,提高性能的脚本我们只搜索新的电子邮件和存储邮箱名称,唯一的ID(唯一的邮箱),一些头信息在MySQL表中。

We have some complex search criteria to query against imap folder, to increase performance of the script we only search on new emails and storing mailbox name,unique id (unique in mailbox), some header information in MySQL table.

我想出了两个问题:


  1. 已删除/已移动项目?

  2. 是否有任何方法来确定附件是否存在? (因为头信息不给任何连接指示器的线索,我试图使用 imap_fetchstructure 但它读取整个消息,包括附件,需要很长时间来处理) li>
  1. How can i keep track on Deleted / Moved items ?
  2. Is there any way to determine attachment exists or not ? ( Because header information doesn't give any clue to attachment indicator , i tried to use imap_fetchstructure but it reads the entire message including attachment which takes a long time to process )

注意


我在后端运行这个脚本以一个固定的间隔(但不是
a cron工作,外部应用程序将初始化脚本在一个正常的
间隔)。另外我使用PHP做所有这些

I am running this script on back end with a regular interval ( But not a cron job, an external application will initialize the script on a regular interval ).Additionally i am doing all these with PHP with its on limitations.

>

推荐答案

首先,在IMAP中,没有要求意味着 FETCH BODYSTRUCTURE 将传送带有附件的完整消息数据。或者你的假设是错误的,或者你的IMAP库有一个严重的错误,或者你在这里使用错误的功能。

First of all, in IMAP, there is no requirement which would imply that FETCH BODYSTRUCTURE would have transfer complete message data with attachments. Either your assumption is wrong, or your IMAP library has a grave bug, or you are using a wrong function here.

其次,你提到跟踪UID,说关于 UIDVALIDITY 的任何事情。请阅读 RFC 3501 了解其含义。没有办法,你可以实现一个应用程序谈话IMAP正确,而不知道协议。更多指针也在 RFC 4549 中给出。

Second, you mentioned keeping track of UIDs but have not said anything about the UIDVALIDITY. Read RFC 3501 to understand what it means. There is no way you could implement an application talking IMAP correctly without knowing the protocol. Further pointers are also given in RFC 4549.

您的第三个问题是要求删除或移动的项目。在基线IMAP,你不能这样做。唯一的方法来知道哪些消息被删除,哪些是新到达的是明确跟踪UID - 假设给出 UIDVALIDITY 并且没有改变,你比较从最后一次以来,你现在得到的UID列表,看看哪些是新的,哪些已经消失。同样,阅读RFC,它们包含所有问题的答案以及如何优化同步过程的建议。还有一个关于IMAP的论题,其中详细介绍了如何进一步改进协议聊天和什么扩展是相关的。这不是一个容易的项目,

Your third question is about asking for deleted or moved items. In baseline IMAP, you cannot do that. The only way to know what messages have been deleted and which are the new arrivals is to track the UIDs explicitly -- assuming the UIDVALIDITY was given and did not change, you compare the list of UIDs since the last time with what you got now, and see which are new and which are gone. Again, read the RFCs, they contain answers to all of your questions as well as suggestions on how to optimize the synchronization process. There's also a thesis about IMAP which goes into much more detail on how to further improve the protocol chat and what extensions are relevant. This is not an easy project, though.

这篇关于阅读电子邮件imap php的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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