Postfix: Send email to PHP

前端 未结 3 940
清歌不尽
清歌不尽 2021-01-22 18:36

Greetings,

Anyone know of a good way to send an email to my postfix server which then opens a PHP script to process this email? I could do cron, but I\'d prefer to do it

3条回答
  •  执笔经年
    2021-01-22 19:21

    You may be able to use a .forward, but probably the easiest way is to configure procmail.

    Edit: here's a sample .procmailrc rule that may help:

    :0 w
    * ^From.*authorized@example.com
    | php /path/to/script.php
    

    If the email comes from authorized@example.com, then it will get passed to the php script. Since this is done from procmail which can be integrated with the mail server, the MySql setup shouldn't impact anything.

提交回复
热议问题