Reputation: 922
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 \r \n From: $name \r \n Reply to: $email";
$headers .= 'Content-type: text/html; charset=iso-8859-1' . "\r\n";
$headers .= 'From: Domain Name [email protected]' . "\r\n";
mail("[email protected]", $subject, $message);
?>
Upvotes: 0
Views: 494
Reputation: 10341
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 \r \n From: $name \r \n Reply to: $email";
$headers .= 'Content-type: text/html; charset=iso-8859-1' . "\r\n";
$headers .= 'From: Domain Name [email protected]' . "\r\n";
mail("[email protected]", $subject, $message, $headers);
?>
That should do it.
Upvotes: 4
Reputation: 28752
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 :)
Upvotes: 0
Reputation:
You need to use your headers I think (see http://php.net/manual/en/function.mail.php)
Upvotes: 0