i have developed a simple php contact form, that’s working fine, but i am unable to format the body of the message as per my requirement, my code is given below, i am getting mail in a single line format,
where i want every information on a new line like this
“Name: Syed Sheeraz Ahmed
Contact No: 03453594552
Email: abc@abc.com
Address: R-47, Sector 9, North city.
Requirement: hello how are you”
<?php
$to = "sheery_1@hotmail.com";
$subject = "From Website Contact Form";
$name = $_REQUEST['name'] ;
$contact = $_REQUEST['contact'] ;
$address = $_REQUEST['address'] ;
$MESSAGE_BODY = "Name: ".$_POST["name"]."<br>";
$MESSAGE_BODY .= "Contact No: ".$_POST["contact"]."<br>";
$MESSAGE_BODY .= "Email: ".$_POST["email"]."<br>";
$MESSAGE_BODY .= "Address: ".$_POST["address"]."<br>";
$MESSAGE_BODY .= "Requirement: ".nl2br($_POST["message"])."<br>";
$message = $_REQUEST['message' + 'address' + 'contact'] ;
$from = $_REQUEST['email'] ;
$headers = "From:" . $from;
mail($to,$subject,$MESSAGE_BODY,$headers);
echo "Mail Sent.";
?>
You want a new line (
\n) not an HTML line break (<br>) since your email isn’t marked as having an HTML body (and emails that have HTML bodies should really have multipart MIME bodies with both plain text and HTML versions since “HTML only” is a nice flag for spam detectors).