Greeting Fellow Programmers,
Got a little problemo. I am writing a form so people can sign up and all of that jazz. I would like the user just hit the reply button so they can respond back to the person without having clicking on the email that they have provided. I have created this variable
$headers = "From: ". $name . "<" . $email. ">
";
$headers .= "Reply-To: " . $email . "
";
$headers .= "Return-path: ". $email;
When I test on my server, I get a weird message in my email inbox. The CGI-Mailer still apears on inbox, the subject line is in the body not where it should be, and all sort of crazyness
Here is the complete code without the email and subject
<?php
$emailPattern = '/^[^@\s]+@([-a-z0-9]+\.)+[a-z]{2,}$/i';
$to = "";
$subject = '';
$name = safe( $_POST['name'] );
$address = safe( $_POST['address'] );
$city = safe( $_POST['city'] );
$state = safe( $_POST['state'] );
$zip = safe( $_POST['zip'] );
$email = safe( $_POST['email'] );
$date_of_birth = safe( $_POST['date_of_birth'] );
$phone = safe($_POST['phone'] );
$reason = safe($_POST['reason'] );
$headers = "From: ". $name . "<" . $email. ">
";
$headers .= "Reply-To: " . $email . "
";
$headers .= "Return-path: ". $email;
$message = "Name: " . $name . "
";
$message .= "Address: " . $address . "
";
$message .= "State: " . $state . "
";
$message .= "City: " . $city . "
";
$message .= "Zip: " . $zip . "
";
$message .= "Email: " . $email . "
";
$message .= "Date of Birth: " . $date_of_birth . "
";
$message .= "Phone: " . $phone . "
";
$message .= "reason: " . $reason . "
";
if (mail($to,$subject,$headers,$message))
{
echo "&Result=success";
} else {
echo "&Result=error";
}
function safe($string)
{
$pattern = "/\r|
|\%0a|\%0d|Content\-Type:|bcc:|to:|cc:/i";
return preg_replace($pattern, '', $string);
}
?>
What am I doing wrong? Thanks in advance.
Gabriel