how can i process incoming mail with php?

后端 未结 3 1024
没有蜡笔的小新
没有蜡笔的小新 2021-01-21 11:32

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?

相关标签:
3条回答
  • 2021-01-21 11:32

    Use a pipe alias to receive the emails.

    0 讨论(0)
  • 2021-01-21 11:45

    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.

    0 讨论(0)
  • 2021-01-21 11:56

    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 讨论(0)
提交回复
热议问题