Need help with a from header for a contact form

I have posted about the contact form script before, but i could not figure it out. The hosting company said I need to have a correct “From” header for it to be able to send. I am pasting the entire code. Can you please tell me what I should add and where to place it. I am a php newbie thanks for your help

[php]

Farr Better Plumbing
        <!-- The contact form starts from here-->
<?php // Routine to check email for problems... function isEmail($email){ return eregi("^[_a-z0-9-]+(\.[_a-z0-9-]+)*@[a-z0-9-]+(\.[a-z0-9-]+)*(\.[a-z]{2,3})$", $email); } $error = ''; // error message $name = ''; // sender's name $email = ''; // sender's email address $subject = ''; // subject $message = ''; // the message itself if(isset($_POST['send'])) { $name = $_POST['name']; $email = $_POST['email']; $subject = $_POST['subject']; $message = $_POST['message']; if(trim($name) == '') { $error = '
Please enter your name!
'; } else if(trim($email) == '') { $error = '
Please enter your email address!
'; } else if(!isEmail($email)) { $error = '
You have enter an invalid e-mail address. Please, try again!
'; } if(trim($subject) == '') { $error = '
Please enter a subject!
'; } else if(trim($message) == '') { $error = '
Please enter your message!
'; } if(get_magic_quotes_gpc()) { $message = stripslashes($message); } // the email will be sent here // make sure to change this to be your e-mail $to = "[email protected]"; // the email subject // '[Contact Form] :' will appear automatically in the subject. // You can change it as you want $subject = '[Contact Form] : ' . $subject; // the mail message ( add any additional information if you want ) $msg = "From : $name \r\ne-Mail : $email \r\nSubject : $subject \r\n\n" . "Message : \r\n$message"; mail($to, $subject, $msg, "From: $email\r\nReply-To: $email\r\nReturn-Path: $email\r\n"); } ?>
              <!-- Message sent! (change the text below as you wish)-->
              <div style="text-align:center;">
                <h1>Congratulations!!</h1>
                   <p>Thank you <b><?=$name;?></b>, your message is sent!</p>
              </div>
              <!--End Message Sent-->


        <?php
            
        if(!isset($_POST['send']) || $error != '')
        {
		}
        ?>


       [/php]

Try changing this:
mail($to, $subject, $msg, “From: $email\r\nReply-To: $email\r\nReturn-Path: $email\r\n”);
To:
[php]
$headers = "From: " . $email . "\r\nReply-To: " . $email . "\r\nReturn-Path: " . $email . “\r\n”;
mail($to, $subject, $msg, $headers);
[/php]
Sometimes it is that the variables are not being placed correctly. To test the new header, just echo it…
echo $headers; And, see if it looks correct.
If this does not solve it, echo all the parts that are in mail() and see if one is not formatted correctly…
One that will cause issues is the $to. It must be a valid email [email protected] without quotes or whatever…
Also, to test this, of course, you have to be on a live server not a local host testing it. (Can’t use PHP mail
functions locally!) Hope that helps, if not post again to THIS post. Do not start a third post as it is hard to answer that way. I answered this same info in the other post, too… Good luck

Sponsor our Newsletter | Privacy Policy | Terms of Service