Search code examples
phppipepostfix-mtaemail-bounces

Postfix: Permission denied trying to pipe bounced emails to a php script


I'm trying to call my php script when an email bounces in Postfix but when an email bounces I get

May 23 19:45:17 development postfix/pipe[5394]: 2064C22132B: to=<ian@rar.com>, relay=bouncer, delay=3778, delays=3778/0.03/0/0.03, dsn=4.3.0, status=deferred (temporary failure. Command output: pipe: fatal: pipe_command: execvp /web/mailer/scripts/bouncer.php: Permission denied )

In the master.cf file I've got

bouncer unix    -       n       n       -       -       pipe    flags=F user=bouncer argv=/web/mailer/scripts/bouncer.php ${sender} ${size} ${recipient}

And in main.cf

default_privs = bouncer

As far as I can see this should work, as it's not a root user but has permissions to execute the script if I su bouncer and run.

Any help would be greatly appreciated, I'm starting to go a bit mad, thank you!


Solution

  • So it turns out selinux was getting in the way, fixed by changing the context on the bouncer.php file, sanity restored!

    chcon -t postfix_pipe_t bouncer.php