PHP Imap 扩展与 Horde Framework imap 客户端(或其他替代方案)
对于 Web 应用程序,我需要使用 php 从 imap 服务器读取邮件。
到目前为止,我已经使用了一个非常简单的脚本和 php imap 扩展,但因为我需要一个强大的解决方案(我也尝试过 pear imap 包,但它对于不同的编码不是很可靠),支持更多功能,如 pgp 加密电子邮件,我一直在考虑使用 horde 框架/imap 客户端。
我不知道仅仅为了 imap 功能是否值得安装和使用(相当复杂的)horde 框架。有什么替代方案或建议吗?使用 horde 与 php imap 扩展相比有哪些优点/缺点?
(该应用程序不应该提供任何网络界面,我只需要解析邮件并将内容/附件保存到数据库)
更新 我尝试了Horde Imap Client,它很容易安装和使用,但与php imap扩展(在php5.3+eAccelerator上)相比,性能似乎有点慢。登录 imap 服务器 + 获取标头需要 8 秒(登录 4.5 秒 + 获取标头 3.5 秒),而使用 php imap 扩展则不到 4 秒(登录 3 秒 + 获取标头 0.5 秒)。我仍在试图弄清楚我是否做错了什么,或者这只是本机 php 库与 php imap 扩展之间的正常差异。
For a web application I need to read mails from an imap server with php.
So far i have used a very simple script and the php imap extension, but because i need a robust solution (i also tried pear imap packages, but it was not very reliable with different encodings), that supports more features like pgp encrypted emails, i have been thinking about using the horde framework/imap client instead.
I don't know if it's worth to install and use the (rather complex) horde framework just for the imap functions. Are there any alternatives or suggestions? what would be the advantages/disadvantages of using horde vs the php imap extension?
(The application is not supposed to provide any webinterface, i just need to parse mails and save contents/attachements to a database)
UPDATE
I tried the Horde Imap Client, it's easy to install and use, but the performance seems a little bit slow compared to the php imap extension (on php5.3+eAccelerator). Login on imap server + fetch headers takes 8 seconds (login 4.5s + fetch headers 3.5s), compared to less than 4 seconds with php imap extension (login 3s + fetch headers 0.5s). I'm still trying to figure out wether i'm doing something wrong or this is just the normal difference between a native php library vs php imap extension.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
您也可以安装 Horde IMAP 库,而无需设置整个框架:
You can install the Horde IMAP library without setting up the whole framework too:
您可以使用 Zend Framework 中的 Zend_Mail 组件。我不知道它是否比部落更复杂/更简单,但你可以只获取该组件及其依赖项,而不需要所有 ZF。
使用 Zend_Mail 阅读消息
You could use the Zend_Mail component from Zend Framework. I dunno if its more/less complex than Horde, but you can grab just that component and its dependencies you dont need all of ZF.
Reading messages with Zend_Mail
部落图书馆在登录邮件服务器时会执行一些基本的内务处理和查询,其中最重要的是“查询收件箱”,这对于大文件夹可能会花费大量时间。
PHP 附带的 IMAP 扩展不会执行此操作。您可以通过安装和使用 Horde_Cache 来加速这些查询。
PHP 附带的 IMAP 扩展有很多问题,例如,它可能很难登录交换服务器、gmail 等。我从经验中发现,值得学习并使用 horde 库来解决这些问题,它应该可以帮助您几个小时就能生产出有用的东西。当涉及到从电子邮件正文中提取 mime 附件之类的事情时,我个人发现 horde 更容易做到这一点。您的里程可能会有所不同。
希望这有帮助!
The horde libraries do some basic housekeeping and queries when they log onto the mail server, the big one being "ENQUIRE INBOX", which can take a significant amount of time with a large folder.
The IMAP extension that comes with PHP does not do this. You can speed up these queries by installing and using Horde_Cache.
The IMAP extension that comes with PHP has many gotchas, for example it can struggle to log into exchange servers, gmail, etc. I have found from experience that it's worth learning and using the horde library to get around these problems, it should take you a couple of hours to produce something that works. When it comes to things like extracting mime attachments from an email body, i personally have found horde to be easier for this. your mileage may vary.
Hope this helps!