I developed a simple php contact form that works fine, but I canβt format the message body according to my requirement, my code is below, I receive mail in single line format,
where I want every information about a new line like this | "Name: Sayed Sherat Ahmed
Contact No: 03453594552
Email: abc@abc.com
Address: R-47, Sector 9, Northern 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."; ?>
source share