Question

I want to use procmail to forward all incoming email to an email address. Normally I would just do this:

:0
! email@domain.com

BUT: In this case I don't know the receiver. Insteasd, the receiver is calculated by a PHP script based on the incoming email content.

So I need something like this:

:0c
| /usr/bin/php /var/www/calculatereceiver.php   <== The output of this script is the $RECEIVER address

:0
! $RECEIVER 

Of course the above code doesn't work. My problem is: How can I manage that procmail forwards the mail to the output of thwe first script?

Best greetings,

Sven

Was it helpful?

Solution

Procmail: program/script output to variable (email on STDIN)

Try the following:

RECEIVER=`/usr/bin/php /var/www/calculatereceiver.php`

:0
! $RECEIVER 

More secure version that may not work with all sendmail look alikes:

RECEIVER=`/usr/bin/php /var/www/calculatereceiver.php`

:0
! -- $RECEIVER

Documentation references

man procmailrc :

Any program in backquotes started by procmail will have the entire mail at its stdin

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top