1

I have configured postfix to run a script when email is received. The script gets tirggered whenever email is received on postfix. However the problem is that it is being triggered on all the email accounts rather than only one account that I added in access file of postfix. Here is my configuration: master.cf

myhook unix - n n - - pipe flags=F user=www-data argv=/var/www/public_html/production/hook/hook.php ${sender} ${size} ${recipient}

smtp      inet  n       -       -       -       -       smtpd -o content_filter=myhook:dummy

And here is my main.cf file:

smtpd_recipient_restrictions =check_recipient_access hash:/etc/postfix/access, permit_sasl_authenticated,permit_mynetworks,reject_unauth_destination

Here is the content of my access file:

robot@domain FILTER myhook:dummy

After making above changes I ran:

postmap access
postfix reload

Still all the emails are being routed to that script rather than only those that are sent to robot@domain

Did I miss something? I have followed this tutorial for configurations:

https://thecodingmachine.io/triggering-a-php-script-when-your-postfix-server-receives-a-mail

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.