I am attempting to do some custom email forwarding. #1 I am on a shared server, which is using qmail, and optionally procmail.
What I am trying to accomplish is some custom email forwarding of one address, based on a schedule. For example, I have a schedule of employees that are working on each weekday, and I have a php script that selects a random employee's email address that is working today.
So I'm trying to just call that script in procmail, and output the result(which is a single email address) on the forward line:
Example:
#Something
LOGFILE=/usr/home/myname/procmail-log
VERBOSE=yes
EXITCODE=99
MAILDIR=/usr/boxes/myname
DEFAULT=/usr/boxes/myname/mybox
SHELL=/bin/sh
MYVAR=$(php -q /usr/home/myname/testemail/emailtester.php)
:0
! $MYVAR
This is not working. At all. I have also tried:
MYVAR=`php /usr/home/myname/testemail/emailtester.php`
as well as just piping it into the forward line:
:0
! |php /usr/home/myname/testemail/emailtester.php
I am COMPLETELY out of my element here... I tried to not even use procmail, and I just piped the whole email over to a php script, from qmail. I need the headers to stay intact, like a normal forward, and that proved to be difficult with PHP, and a little beyond my scope.( I managed to create an infinite email loop) So, I would rather not try that again.
I could just try to script this in perl, which I have never used, but I need the schedule to be administerable from a web interface, or at least in a user friendly way.
Any help, or suggestions would be appreciated at this point, thanks
EDIT:
Well, since I cant put code in a comment, I'll just edit here.
Now getting this in my log:
Folder: /usr/local/bin/php /usr/home/idnani/testemail/emailtester.ph 1679
"rocmail: Executing "/usr/local/bin/php,/usr/home/idnani/testemail/emailtester.php
Could not open input file: /usr/home/idnani/testemail/emailtester.php
When I use with :0fw I get:
"rocmail: Executing "/usr/local/bin/php,/usr/home/idnani/testemail/emailtester.php
Could not open input file: /usr/home/idnani/testemail/emailtester.php
procmail: [69907] Thu Jun 16 14:04:17 2011
procmail: Program failure (1) of "/usr/local/bin/php"
procmail: Rescue of unfiltered data succeeded
EDIT: Figured it out!
Found the correct way after MUCH trial and error.
Don't even use the pipe at, all, and you do need the ! forward symbol:
Final Rule:
:0
! `/usr/local/bin/php -f $HOME/emailtest/emailtester.php`
So simple... I'm a little mad it took me hours to figure this out, thanks everyone for helping to point me in the right direction!