I'm using the php mail() function and I'd like to change where the mail is comming form, ie: from the default site email to a specific email address. I'm using Dreamhost as my hosting provider.
I've tried this:
<?php
$name = $_GET['name'];
$email = $_GET['email'];
$comment = $_GET['comment'];
$todayis = date("l, F j, Y, g:i a") ;
$subject = "A message sent on ".$todayis." from ".$name." via the playatics website";
$message = " Message: $comment
From: $name
Reply to: $email";
$headers .= 'Content-type: text/html; charset=iso-8859-1' . "
";
$headers .= 'From: Domain Name contact@domain.com' . "
";
mail("somemail@domain.com", $subject, $message);
?>
You need to use your headers I think (see http://php.net/manual/en/function.mail.php)
Not directly an answer to your question, but check out PHPMailer if you plan on doing a fair bit of emailing in PHP. It makes things nice and easy :)
You are a whisker away from the answer here. You are setting a variable $headers
, but you are not using it when calling the mail()
function.
<?php
$name = $_GET['name'];
$email = $_GET['email'];
$comment = $_GET['comment'];
$todayis = date("l, F j, Y, g:i a") ;
$subject = "A message sent on ".$todayis." from ".$name." via the playatics website";
$message = " Message: $comment
From: $name
Reply to: $email";
$headers .= 'Content-type: text/html; charset=iso-8859-1' . "
";
$headers .= 'From: Domain Name contact@domain.com' . "
";
mail("somemail@domain.com", $subject, $message, $headers);
?>
That should do it.