I've currently got a Postfix service running which sends and receives emails fine. I'm trying to alias the "test" address to run a PHP script. See excerpt of aliases file below.
test: "| php -q /var/blahblahblah/php/test.php"
Here is the contents of test.php. This seems to run correctly in command line.
#!/usr/bin/php <?php $file = fopen("/tmp/postfixtest", "a"); fwrite($file, "Script successfully ran at ".date("Y-m-d H:i:s")."\n"); fclose($file); ?>
Below is an excerpt of the mail.log showing the main lines of interest.
postfix/qmgr: 02BE9472A: from=<firstname.lastname@example.org>, size=1681, nrcpt=1 (queue active) postfix/virtual: 02BE9472A: to=<email@example.com>, relay=virtual, delay=0.45, delays=0.42/0.01/0/0.02, dsn=2.0.0, status=sent (delivered to maildir) postfix/qmgr: 02BE9472A: removed
Note the delivered to maildir bit in brackets. Is this supposed to say something like "delivered to script"?
All the files are set to 777 permissions for now and the aliases files are kept updated by using
It seems as if the PHP script isn't being called properly but I get no 'errors' in any of the logs.
Has anyone experienced or fixed this before?
newaliases.postfix, or just restart postfix - Michael Berkowski 2012-04-04 02:54
test: "|php -q /path/to/script.php"Michael Berkowski 2012-04-04 02:55
|command Mail is piped into command. Commands that contain special char- acters, such as whitespace, should be enclosed between double quotes. See local(8) for details of delivery to command. When the command fails, a limited amount of command output is mailed back to the sender. The file /usr/include/sysexits.h defines the expected exit status codes. For example, use "|exit 67" to simulate a "user unknown" error, and "|exit 0" to imple- ment an expensive black hole.
so I would expect this is what is meant:
test: |"php -q /var/blahblahblah/php/test.php"