Chaning output of php mail message

Hi I’m implenting a basic php validation mail function. In the process.php file where all the magic works I’d like to change this;

if(!$error)
{
$mail = mail(WEBMASTER_EMAIL, $subject,
     "From: ".$name." <".$email.">\\r\
"
    ."Reply-To: ".$email."\\r\
"
    ."Message: ".$message."\\r\
");

if($mail)
{
echo 'OK';
}

To somthing like;

if(!$error)
{
$mail = mail($email, $subject = 'Comment from website',
     "From: ".$name." <".$email.">\\r\
"
    ."Reply-To: ".$email."\\r\
"
    ."Message: ".$message."\\r\
");

if($mail)
{
echo 'OK';
}

So when I get the mail I want the person who enters their $email address in the ‘From:’ line rather than the mail server address and I want the subject: line to be static “Comments from website”…

Any help much appriciated.

Hi,
Try this code:


$email = isset($_POST['field_name']) ? $_POST['field_name'] : '';
if(!$error) {
$mail = mail(WEBMASTER_EMAIL, 'Comments from website',
     "From: ".$name." <".$email.">\\r\
"
    ."Reply-To: ".$email."\\r\
"
    ."Message: ".$message."\\r\
");

if($mail) { echo 'OK'; }

The ‘field_name’ is the name of the form field in which the user adds its e-mail address.