how can i process incoming mail with php?

后端 未结 3 1025
没有蜡笔的小新
没有蜡笔的小新 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: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.

提交回复
热议问题