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

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

问题描述

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

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.

我正在寻找能够正确分离消息部分的东西,例如收件人、发件人、正文等.理想情况下,它能够处理所有常见的编码方法,例如 base64、uuencode、引用的可打印、等

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.

如果同一邮件的纯文本和 html 版本都包含在一封电子邮件中,我希望它知道它们之间的区别,以便我可以选择我希望显示的部分.

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.

我看到 PHP 有一组以 imap 开头的函数,看起来它们可以做我想做的事,但我不确定不尝试一下.

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.

目前我正在对 PHP 中的消息进行即时解码,这就是我寻找 PHP 替代解决方案的原因.

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.

推荐答案

有趣的你应该问...我现在实际上正在研究一个简单的通知系统.我刚刚完成了弹跳管理器,我使用 Zend_Mail 来实现.它几乎具有您正在寻找的所有功能……您可以连接到邮箱(POP3、IMAP、Mbox 和 Maildir)并从中提取邮件以及对所有这些邮件进行操作.

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

它处理多部分消息,但这些部分可能很难处理.我很难弄清楚哪个部分是我正在使用的 NDR 中附加的原始消息部分,但我感觉我只是错过了文档中的某些内容.我不确定它是如何处理编码的,因为我的用法相当简单,但我很确定它对你提到的所有编码都有规定.查看文档并浏览 API.

It handles multipart messages, but the parts can be hard to work with. I had 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. I'm not sure how it handles encoding, because my usage was fairly simple but I'm pretty sure it has provisions for all the encodings you mentioned. Check out the docs and browse the API.

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

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