Postfix won't pipe to PHP file through aliases file
I'm trying to pipe from postfix to a command. According to Postfix logs it worked, but when I check the command it didn't. This is a fresh postfix install. This is my alias file:
# See man 5 aliases for format
postmaster: root
support: "| /usr/bin/php -q /var/www/pipe/pipe.php"
I run sendmail [email protected]
then type it and then on a separate line type .
and it goes. I check the postfix log /var/log/mail.log
and this is what it states:
Nov 2 15:32:33 server3 postfix/local[13284]: 42C429E0B5: to=<[email protected]>, relay=local, delay=156, delays=156/0.01/0/0.05, dsn=2.0.0, status=sent (delivered to command: /usr/bin/php -q /var/www/pipe/pipe.php)
So according to that it worked, but it doesn't. If I run echo 'text' | /usr/bin/php -q /var/www/pipe/pipe.php
it does work just fine.
Any ideas what I did wrong?
I know piping is working, I originally checked it by running that command above WITHOUT the quotes, so just support: | /usr/bin/php -q /var/www/pipe/pipe.php
What it did there was append my email header and all to the file pipe.php. So I know postfix was piping it, but when I put in the quotes it says it's going but it's not according to my script.
I was only missing one line in my /etc/postfix/main.cf
file.
default_privs = www-data
Which is weird since I tried running as 777 the file, so in theory it should have worked. Oh well it works this way now. So in short set privs of the owner of the file since Postfix defaults to user nobody
.