Connecting Tech Pros Worldwide Help | Site Map

email parameters

  #1  
Old June 13th, 2009, 06:55 PM
n8kindt's Avatar
Familiar Sight
 
Join Date: Mar 2008
Location: Southern California
Posts: 221
i have a dynamic database-driven email forwarding system which is called when the physical email address that an email is sent to does not reside on the server. the email is passed on to my script using the "default email address" (which, in this case is being piped to a script). the php script that the email is piped to searches the email header to determine the new recipients and sends the email on its merry way using file_get_contents("php://stdin"). the flaw in this is if an email is sent using bcc, the recipient does not appear in the header. so how can i possibly tell who the recipient is? is there a way to determine what recipient the email system is working with after it gets routed to the default email address? something like a file_get_contents("php://stdWHO_SENT_THE_EMAIL") ?? lol

my best guess is that i would need more than just a hashbang( #!/usr/bin/php ) to pass a variable to php somehow. but google isn't helping me with that so this is where i turn to. thanks for your time!
  #2  
Old June 14th, 2009, 02:23 AM
Atli's Avatar
Moderator
 
Join Date: Nov 2006
Location: Iceland
Posts: 3,701
Provided Answers: 4

re: email parameters


Hi.

Knowing nothing about email forwarding systems, and a very limited amount about PHP in CGI mode... this might sound stupid, but...

I assume that somewhere along the line, in your email forwarding system, your are calling your script.
Something like "/usr/bin/php /path/to/file.php".

Could you not just add the email address to that and fetch it inside PHP using the $argv array?
Assuming the path "/usr/bin/php /path/to/file.php user@example.com":
Expand|Select|Wrap|Line Numbers
  1. $recipient = $argv[1];
If not, then I'm all out of ideas.
(Got another thing to put on my "to research" list tho :P)
  #3  
Old June 14th, 2009, 07:39 AM
n8kindt's Avatar
Familiar Sight
 
Join Date: Mar 2008
Location: Southern California
Posts: 221

re: email parameters


ah, i think you got me on the right track. i had never even heard of the $argv array so that was a BIG help. however, i'm unsure what variable the recipient's email address is stored in.

i think this site has the answer to my problems: http://binarios.com/lnb/qmail.html (the email system i have is qmail - i'm 99% sure of it.

from what i gathered from the information on that page i should be able to set my default email script to
Expand|Select|Wrap|Line Numbers
  1. | \pipe2scripts_dir\myscript.php "$RECIPIENT"
and retrieve the $RECIPIENT variable from the $argv array in php.

unfortunately, my hosting provider automatically adds slashes to the quotation marks so i've tried without the quotation marks and experimented with some other variations but haven't had any luck. i might have to submit a ticket to see if they can edit the code and manually remove the slashes.

i will feel silly if they go thru all that trouble and it doesn't work though. what do you think?
  #4  
Old June 17th, 2009, 09:40 PM
n8kindt's Avatar
Familiar Sight
 
Join Date: Mar 2008
Location: Southern California
Posts: 221

re: email parameters


looks like i won't have to go into this messy business. i'm not sure how or why i didn't see this before but when an email is passed thru the qmail system it automatically prepends the intended recipient in the header (usually says "... for <user@domain.com>"). it's buried in there and requires a slightly busy regexp to look for and pick out the email address but... problem solved! :)
  #5  
Old June 17th, 2009, 11:34 PM
Atli's Avatar
Moderator
 
Join Date: Nov 2006
Location: Iceland
Posts: 3,701
Provided Answers: 4

re: email parameters


I'm glad to hear that :)

A far less messy solution to.
Reply


Similar Threads
Thread Thread Starter Forum Replies Last Post
email parameters n8kindt answers 1 June 13th, 2009 06:53 PM
adding parameters tshad answers 2 November 19th, 2005 02:44 PM
oleDb Command Parameters Bill Cart answers 3 November 15th, 2005 11:17 AM
using Command to set Parameters and Recordset to retrive the Query Bruno Alexandre answers 5 July 19th, 2005 12:14 PM