tags:

views:

73

answers:

3

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);

?>
A: 

You need to use your headers I think (see http://php.net/manual/en/function.mail.php)

RC
A: 

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 :)

Michael Mior
+3  A: 

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.

Lucanos
holy canoli! haha! yes I was whiskers away, that did it! Thanks
JoeM05
Any chance you can mark this answer as correct then? (I think you will see a checkmark to the left of my response.) Just means that this question will be marked as closed (and I get a little bit of reputation for the answer).
Lucanos