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: [email protected]
Address: R-47, Sector 9, North city.
Requirement: hello how are you"
<?php
$to = "[email protected]";
$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.";
?>
How To Format an Email Message. Your email message should be formatted like a typical business letter, with spaces between paragraphs and no typos or grammatical errors. Don't mistake length for quality—keep your email brief and to the point. Avoid overly complicated or long sentences.
HTML formatting allows you to change the format of the text in your email as well as include pictures. Formatting options include font, font size and color, font style (bold, italic, underline), highlight color, indent and spacing, and bullet and numbering styles.
Use @ in the body of a message or meeting invite In the body of the email message or calendar invite, enter the @ symbol and the first few letters of the contact's first or last name.
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).
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With