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 [EMAIL PROTECTED] to it, but I want
 to be able to dynmaically change [EMAIL PROTECTED] to [EMAIL PROTECTED] 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 = "[EMAIL PROTECTED]";
$admin_email = "[EMAIL PROTECTED]";
$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

--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



Reply via email to