Results 1 to 3 of 3
I am using a form to mail script in php to send the contents of forms filled out on my site into emails. The email server and webserver are both ...
- 04-26-2005 #1Just Joined!
- Join Date
- Jan 2005
- Location
- UK
- Posts
- 77
Changing from address of server generated mail
I am using a form to mail script in php to send the contents of forms filled out on my site into emails. The email server and webserver are both on the same maching, running qmail and php5. What i want to do is change the 'from' address of mail that is sent, to something like mailer@mydomain.com. I know i can set a from address in the forms, but i also have a few scripts that run automatically sending emails and i dont want to change them.
- 04-27-2005 #2Just Joined!
- Join Date
- Jan 2005
- Location
- UK
- Posts
- 77
anyone?
- 05-10-2005 #3Just Joined!
- Join Date
- May 2005
- Location
- Ontario, Canada - Eh!
- Posts
- 17
Here's what I've got as a helper
Now of course there's some other fields/variabled to be set, but this gives you a general idea. May not be the best programming, but I know it works - gets used for my work everyday. This came from the page that sends the mail - i've got it setup as a 2 page form, first one passing the information to this page. So the variables aren't exactly as they may be needed for your application.
#############################################
// SETTING THE VARIABLES
$toemail = 'Whoever <emailddress@theirdomain.com>';
$ccemail = 'Someoneelse <emailaddress@domain.com>';
$bccemail = 'Administrator <admin@mydomain.com>';
// EMAIL MESSAGE HEADERS
$headers = 'MIME-Version: 1.0' . "\r\n";
$headers .= 'Content-type: text/html; charset=iso-8859-1' . "\r\n";
$headers .= 'To: ' . $toemail . "\r\n";
$headers .= 'From: ' . $bccemail . "\r\n";
$headers .= 'Cc: ' . $ccemail . ',' . $toemail . "\r\n";
$headers .= 'Bcc: ' . $bccemail . "\r\n";
// SENDING THE EMAIL
mail($to, $subject, $message, $headers);
echo "<center>SUCCESS!
Mail has been sent!</center>";
#############################################
Running with PHP5 and Apache 2.
Hope it helps


Reply With Quote
