Re: Mail From option in PHP.ini
| From: | Peter Torraca | Date: | Mon, 21 Jul 2003 14:46:36 +0000 |
| Subject: | Re: Mail From option in PHP.ini | ||
| References: | 1 | Groups: | php.general |
| Request: | Send a blank email to php-general+get-156078@lists.php.net to get a copy of this message | ||
On 07/18/2003 12:00 PM, Brian S. Drexler wrote:
Ok, I want to specify who the mail is coming from by using the sendmail_path option in the PHP.ini. I've added the -fme@mydomain.com to it, but I want to be able to dynmaically change me@mydomain.com to you@mydomain.com or whatever else. Anyone have any ideas how I can do this? I'm pulling the e-mail I'd like to change it to from a MySQL database but can I rewrite the php.ini file on the fly or am I stuck. Any help is greatly appreciated. Why not just add the From: header to the fourth mail() param? Something like this:$email = "user@wherever.org"; $admin_email = "webmaster@math.purdue.edu"; $body = "blah blah blah"; $mail = mail($email, "Information you requested", $body, "From: $admin_email"); I've found that this sets the headers the way most clients expect to see them. We use it a lot to tidy up emails set from "reset your password" functions and the like. It should be trivial to set the From: header based on a db result or whatever. There is a much expanded version of this solution regarding sending emails with attachments through mail() on in the online php manual, check out "kieran dot huggins at rogers dot com"'s comments and some others on the http://us4.php.net/mail page (it's a 06-Nov-2002 comment). I'm coming in a bit late to this conversation -- hopefully I'm not too far off base with this reply. If I am, sorry! peter -- Peter Torraca Webmaster, Math Department Purdue Univ., Math 813 765-494-9998