PHP4: extra headers in mail() ?

From: Date: Tue, 05 Dec 2000 08:45:22 +0000
Subject: PHP4: extra headers in mail() ?
Groups: php.general 
Request: Send a blank email to php-general+get-28698@lists.php.net to get a copy of this message
More specifically, how to override headers which seem to be generated by the system: Let's say http(s)d runs as user 'webadmin'. Then, try as I might, the Return-Path header will be <webadmin@domain> -- what if, for the purpose of a db-based notification system, I'd like to have the Return-Path header set to something which will more acurratley identify which user bounced the message (anyone who's run a large mailing list knows what a PITA nonstandard email implementations and forwards are for listadmins) -- for instance: $DBname = "somedatabase"; $mailSubject = "as appropriate to the notification"; $mailBody = "would have been provided"; // (do database calls to get email addresses, looping on each one) // for simplicity, assume the following two keys are retrieved from // the database: $userAddress = "someschumuck@otherdomain"; $userDBkey = "028361257623"; // some hashed keyvalue // generate checkdigits (used to help the bounce processor POSITIVELY // validate the userdb key before ever performing a db lookup. This // also helps foil forged bounces (just in case), since a bounce cannot // be generated merely by changing the db key sequence). $userDBcheck = gencheckcode($userDBkey); $mailHeaders = "Return-Path: MailProc-$DBname-$userDBkey-$userDBcheck@ourdomain\n"; if ( mail( $userAddress, $mailSubject, $mailBody, $mailHeaders ) ) { // success } else { // log an error event, and perhaps how far along we got // in case a resume can be manually invoked. } The Return-Path is important to be able to set, because it is where a remote mail delivery system should attempt to send a bounce to -- and if at our end we have a script (procmail in my case, but any number of scripting languages could be used) to handle incoming messages at the address(es), then bounce handling can be automated, and as long as the bounce is actually to the coded address in the Return-Path, the system can take measures to either suspend the account (say, after five or some other threshold of bounces) or automatically remove it (in high volume applications, where a deadbeat user is invariably a problem). Please tell me that the Return-Path can be overriden in PHP -- because it is trivial to override it in procmail, but I shouldn't need to relay it through my own server just to change the header. --- Please DO NOT carbon me on list replies. I'll get my copy from the list. Sean B. Straw / Professional Software Engineering Post Box 2395 / San Rafael, CA 94912-2395

« previous php.general (#28698) next »