Web Hosting Talk







View Full Version : piping all email to PHP


pphillips
04-19-2006, 05:21 PM
Hi guys, I have quite a serious issue I'm trying to figure out. I forward *all* incoming email to a PHP app we wrote that processes it. This is how it works:

1. All incoming mail is piped to our PHP app.
2. Our PHP app reads the headers to:/cc: (attemps to read bcc: also but they never exist on bcc's) to find out what address it was sent to at our domain.
3. Our app processes the email differently based on the address it was sent to via an algorithm.

We use to have a forwarder for each possible address that when piped would pass a value to our script, and it would react based on that value. Now we have an extremely large number of possible addresses to work with and it makes more sense to forward all incoming mail to the app and deduct what address it was sent to. It works perfect if the email is in the to: or cc: headers, but if it is bcc:'d it breaks.

So, my question is: Is there any way to pass the email address to the script when piping the email? Seems the only way my script will be able to tell what incoming bcc'd addresses are is if the mail server tells it. I wonder if there is some type of shell scripting that can be used such as | /path/to/app.php %emailaddress%

Someone said that %1 contains the email address in sendmail, but that they were never able to get it work via "| /path/to/app.php %1".


Thanks so much for your help on this!