September 26, 201214 yr How do I get this writing to be bold: $sent = mail ($to, $subject,"Name: $fullname\r\n\r\nCompany: $company\r\n\r\nEmail: $email\r\n\r\nTel No: $telno\r\n\r\nEnquiry: $enquiry", $headers); Edited September 26, 201214 yr by POWERPLAY27
September 26, 201214 yr How do I get this writing to be bold: $sent = mail ($to, $subject,"Name: $fullname\r\n\r\nCompany: $company\r\n\r\nEmail: $email\r\n\r\nTel No: $telno\r\n\r\nEnquiry: $enquiry", $headers); u have to set the content-type in your headers to allow html then u can put html tags directly inside ur emails
September 26, 201214 yr You're now venturing into HTML email territory, Some users may not have set their emmail client to view HTML emails, and it is more complicated to send them. As Webdesigner93 says, $headers = ‘MIME-Version: 1.0′ . “\r\n”; $headers .= ‘Content-type: text/html; charset=iso-8859-1′ . “\r\n”; $headers .= ‘From: $admin'; Then code the mail function $sent = mail ($to, $subject, "<span style=\"color: red;\">Name:</span> $fullname\r\n\r\n<span style=\"color: red;\">Company:</span> $company\r\n\r\nEmail: $email\r\n\r\n<span style=\"color: red;\">Tel No:</span>$telno\r\n\r\n<span style=\"color: red;\">Enquiry:</span> $enquiry", $headers); might do it but I haven't tested. Edited September 26, 201214 yr by Wickham
September 26, 201214 yr Author Tried it, can't get it to work. I will just leave it as it is, as long as the information is sent to email I am happy. Edited September 26, 201214 yr by POWERPLAY27
September 27, 201214 yr I was a bit simplistic with my reply and this forum has a habit of changing vertical quotes (single and double) intop sloping quotes, even though I copy/pasted from vertical quotes. This worked, sent via my own domain server: <!doctype html> <html> <head> <meta name="keywords" content="Wickham"> <meta name="description" content="HTML and CSS "> <title>Form to send html email</title> <meta http-equiv="content-type" content="text/html; charset=utf-8"> </head> <body> <div id="contact"> <form class="contactcontent" name="myForm" METHOD="post" ACTION="powerplay120927.php" > <label for="fullname">Full Name:</label> <input type="text" id="fullname" name="fullname" size="40" ><br /><br /> <label for="company">Company:</label> <input type="text" id="company" name="company" size="40" ><br /><br /> <label for="email">Email Address:</label> <input type="text" id="email" name="email" size="40" ><br /><br /> <label for="telno">Contact Tel No:</label> <input type="text" id="telno" name="telno" size="20" ><br /><br /><br /><br /> <label for="enquiry">Please Insert Your Enquiry Here:</label> <br /> <textarea name="enquiry" id="enquiry" rows="10" cols="65"></textarea><br /><br /> <input type="submit" id="submit" value="Submit" name="submit"/><input type="reset" id="clearFrm" Value="Clear Form" name="Reset"/> </form> </div> </body> </html> powerplay120927.php action file <?php $to = "mail@my-domain.com"; $subject = "Contact_Us"; $fullname = $_POST['fullname']; $company = $_POST['company']; $email = $_POST['email'] ; $telno =$_POST['telno']; $enquiry =$_POST['enquiry']; $admin= "mail@my-domain.com"; $headers = 'MIME-Version: 1.0' . "\r\n"; $headers .= 'Content-type: text/html; charset=iso-utf-8' . "\r\n"; $headers .= "From: $admin"; $message = " <html> <head> <title>HTML & CSS Tutorial</title> </head> <body> <p><span style=\"color: red;\">Name:</span>" . " $fullname" . "<br><br><span style=\"color: red; \">Company:</span>" . " $company" . "<br><br>Email: " . "$email" . "<br><br><span style=\"color: red; \">Tel No:</span>" . "$telno" . "<br><br><span style=\"color: red;\">Enquiry:</span>" . " $enquiry" . "</p></body></html> "; $sent = mail ($to, $subject, $message, $headers); if($sent) {print "Thank you, we have received your enquiry and we will try to respond back to you within 48 hours."; } else{ print "We encountered an error and did not receive your enquiry.";} ?> I tested the above using my domain for my email address. However, there are security issues and some security code should be added to check email addresses and top prevent header injection. Edited September 27, 201214 yr by Wickham
Create an account or sign in to comment