如何使用php处理传入邮件? [英] how can i process incoming mail with php?

查看:128
本文介绍了如何使用php处理传入邮件?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我假设我需要在我的服务器(LAMP)上指出MX记录, - 什么进程传入电子邮件?



是否有任何现有的PHP图书馆这样做?

解决方案

你不想使用PHP作为邮件服务器。您有两个选项:


  1. 设置传递新的经典电子邮件服务器(postfix,sendmail,exim等)消息到本地邮箱。使用IMAP或POP从PHP访问该邮箱,并从中拉出邮件。或者,同样的方法也可以与(虚拟)任何远程邮件服务一起使用,从而减轻了管理邮件服务器的责任。 (你可能会发现这是一个邮箱不值得的。)这种方法通常会每隔几分钟通过cron运行,所以如果需要,你不会得到即时激活。 / p>


  2. 设置一个经典的电子邮件服务器(postfix,sendmail,exim等),并使用procmail或类似的方式在交货时拦截邮件,并将其管理到PHP脚本。这种方法会在电子邮件到达的时刻触发脚本,所以你将没有像#1中的滞后时间。但是,配置更困难(特别是如果您之前没有维护过邮件服务器),并且不适用于大多数外部托管电子邮件服务。



I assume I will need to point MX records at my server (LAMP), -- what processes the incoming e-mail message?

Are there any existing PHP libraries to do this?

解决方案

You don't want to use PHP as a mail server. You've got two options:

  1. Set up a classic email server (postfix, sendmail, exim, etc) that delivers new messages to a local mailbox. Use IMAP or POP to access that mailbox from PHP, and pull messages out of it. Alternatively, this same method may be used with (virtually) any remote mail service as well, thus relieving you of the duty of administering a mail server. (Which you'll likely find to be not worth it for the sake of one mailbox.) This method would usually be run via cron every few minutes, so you're not going to get "instant" activation if that's a requirement.

  2. Set up a classic email server (postfix, sendmail, exim, etc) and use procmail or similar to intercept messages at delivery time, and pipe them to a PHP script. This method will fire the script the instant the email arrives, so you'll have no lag time like in #1. However, it's more difficult to configure (especially if you haven't maintained a mail server before) and won't work with most external hosted email services.

这篇关于如何使用php处理传入邮件?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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