在PHP中处理电子邮件解析/解码的最佳方式? [英] Best way to handle email parsing/decoding in PHP?

查看:136
本文介绍了在PHP中处理电子邮件解析/解码的最佳方式?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

目前,我正在使用PEAR库的mimeDecode.php来解析传入的电子邮件。似乎有很多问题,并且无法解码大量消息,所以我想更好地替换它。



我正在寻找东西它能够正确分离消息的部分,例如,从,身体等。理想情况下,它将能够处理所有常见的编码方法,如base64,uuencode,引用的可打印等。



在单个电子邮件中包含相同消息的纯文本和html版本的情况下,我最理想的是知道它们之间的区别,以便我可以选择我希望显示的部分。



我在这个时候不用担心附件,但是如果我想在未来实现这一点



我看到PHP有一组功能,从imap这个词开始,他们可能会做我想要的,但我不确定没有尝试过。 / p>

目前我正在做飞行编码PHP中的消息,这就是为什么我正在寻找一个PHP替代解决方案。



有没有人有经验可以指出我的方向正确?我不喜欢开始使用一些最终不会从长远来看我需要的东西。

解决方案

问...我现在正在一个简单的通知系统上工作。我使用 Zend_Mail 完成Bounce Manager的完成。它具有几乎所有的功能,您可以...您可以连接到一个mialbox(Pop3,IMAP,Mbox和Maildir),并从中提取消息以及操作所有这些消息。



它处理多部分消息,但这些部分可能很难处理。我很难很难找出哪个部分是我正在使用的NDR的附加原始消息部分,但是我有一种感觉,我只是错过了文档中的某些东西。我不知道如何处理编码,因为我的使用相当简单,但我相当确定它提供了您提到的所有编码...查看文档并浏览API。


Currently I'm using the PEAR library's mimeDecode.php for parsing incoming emails. It seems to have a lot of issues and fails to decode a lot of messages, so I'd like to replace it with something better.

I'm looking for something that is able to properly separate parts of the message, such as to, from, body, etc. Ideally it would be able to handle all common encoding methods such as base64, uuencode, quoted printable, etc.

In situations where both plain text and html versions of the same message are contained in a single email, I would ideally like it to know the difference between them so I could choose which part I wished to display.

I'm not worried about attachments at this point in time, but it would be nice for it to have knowledge of them in case I want to implement that in the future.

I saw PHP has a group of functions that start with the word imap that appear they may do what I would like, but I am unsure without trying them out.

Currently I am doing on-the-fly decoding of the messages in PHP, which is why I am looking for a PHP replacement solution.

Does anyone have an experience with this that could point me in the right direction? I'd hate to start using something that would end up not doing what I need in the long run.

解决方案

Funny you should ask... Im actually working on a simple notification system now. I jsut finished up the Bounce Manager with i use Zend_Mail to implement. It has pretty much all the features your looking for... you can connect to a mialbox (Pop3, IMAP, Mbox, and Maildir) and pull messages from it as well as operate on all those messages.

It handles multipart messages, but the parts can be hard to work with. I hard a hard time figuring out which part was the attached original message part in the NDR's i was working with, but i have a feeling i just missed something in the documentation. Im not sure how it handles encoding because my usage was fairly simple but im pretty sure it has provisions for all the encodings you mentioned... Check out the docs and browse the API.

这篇关于在PHP中处理电子邮件解析/解码的最佳方式?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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