I'm trying to have a form on my website where people can fill it out to request a quote. It will enter the quote request into a database and then send me an email with the details.
My code below enters all the information into the database fine. However, the emails are not looking too good.
Here is an example of what an email looks like when the visitor uses line breaks and ' in the fields:
This is just a simple test. Nothing but a test.\r\n\r\nYep, this is just a test.\r\nAin\'t that cool?
$name="$_POST[name]";
$email="$_POST[email]";
$phone="$_POST[phone]";
$message="$_POST[service]";
$ip=$_SERVER['REMOTE_ADDR'];
$name = stripslashes($name);
$email = stripslashes($email);
$phone = stripslashes($phone);
$message = stripslashes($message);
$name = mysql_real_escape_string($name);
$email = mysql_real_escape_string($email);
$phone = mysql_real_escape_string($phone);
$message = mysql_real_escape_string($message);
// Make sure all required fields are used
if(!$name){ die("Please go back and tell us your name"); }
if(!$email){ die("Please go back and tell us your email address"); }
if(!$message){ die("Please go back and tell us what type of service you are looking for"); }
// Now send the email here
$message = wordwrap($message, 90);
$to = 'Name <email@email.com>';
$subject = 'Subject Here';
$message2 = "$name\n$email\n$phone\n\n$message\n\n======================================\nThis quote request was sent from:\n$_SERVER[HTTP_REFERER]";
'Reply-To: $email' . "\r\n" .
'X-Mailer: PHP/' . phpversion();
$headers .= 'Content-type: text/html' . "\r\n";
mail( "$to", "$subject", $message2, "From: $name <$email>", $headers );