I want to set up an email address that executes a script with every incoming email, so in my /etc/aliases, I did this:
runscript: |/usr/local/bin/email_reading_script.py
Then I rebuilt the postfix alias db with sudo postalias /etc/aliases, and then sent an email to runscript@localhost. That’s when the fun began. The script is run by nobody/nogroup, so it couldn’t log to my logging directory, because I require people to be in the adm unix group.
Then I created a user named runscript, and moved that | /usr/local/bin/email_reading_script.py
line into a .forward file. I added adm to runscript’s unix groups.
AND STILL NO JOY.
I don’t know why, but when the script runs, the shell only seems to get the primary group. So, I kept getting permission-denied errors. I finally got stuff to work when I set adm to be the primary group for my runscript user. Now everything is OK.
This ate up the better part of the @#$@#$ing day. Grr.
If this didn’t work, I was going to install procmail and go down that route.
Am using ubuntu hardy heron.
Just stumbled into your site from the search engine. Keep up the excellent work. …
I think it's because your alias is not the unix user. The script is run by postfix, whose default user is 'nobody'.
Try to write a file in /tmp with your script, and check the actual unix user that was used.
I think the default postfix user can be changed in /etc/postfix/master.cf
Thanks for the tip!