In sendmail, %1 is the variable that's used by virtusertable to refer to the email address of the current email. I just tried a number of different ways to get Sendmail's aliases file to pass that to a PHP script and I was not able to get it to work. I tried all of the following:
tully: "|/usr/bin/php /usr/local/directory/mail.php %1"
tully: "|/usr/bin/php /usr/local/directory/mail.php "%1
tully: "|/usr/bin/php /usr/local/directory/mail.php?email=%1"
and a bunch more but %1 never seemed to get passed to the PHP script.
Here is a way you can get this to work in a pinch. First, here's how I configure Sendmail to pipe email to a script:
tully-script: "|/usr/bin/php /usr/local/mail.php"
You could pipe the email to another script that then includes mail.php like this:
tully-script: "|/usr/local/php /usr/local/tully.php"
steve-script: "|/usr/local/php /usr/local/steve.php"
tony-script: "|/usr/local/php /usr/local/tony.php"
And in that example, tully.php would say
<?
$email_address = "tully@mydomain.com";
include("mail.php"); ?>
?>
Of course, the first option is better if you can get it to work because it will work for every address at your company and you won't need to keep adding new ones manually.
I don't think you need to do this as a shell script. There should be a way to get sendmail to pass the address to the PHP script but I couldn't find it. (Please let me know if you do).