开发者

how can i process incoming mail with php?

开发者 https://www.devze.com 2023-03-08 15:38 出处:网络
I assume I will need to point MX records at my server (LAMP), -- what开发者_运维知识库 processes the incoming e-mail message?

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.


Use a pipe alias to receive the emails.


I would recommend you to do processing in Perl (python is also ok, but Perl has very similar syntax to PHP), which is much more suitable for the task. You can also find a lot of libraries through CPAN there.

http://search.cpan.org/~rjbs/Email-Simple-2.100/lib/Email/Simple.pm

0

精彩评论

暂无评论...
验证码 换一张
取 消