I am trying to add my own custom contact form to a Blogger website project. I’ve got the contact form HTML code in the Blogger template and its own PHP file running on a server, which link I point to the form tag action. It sends email and both platforms seem to communicate well. Among many improvements I am currently making. My main concern is to learn how to send HTML formatted emails. Everytime a user submits a message, I would like to receive it in HTML format. The CSS below is meant to test this feature which later I will develop.
UPDATE:
<?php ... $headers = 'MIME-Version: 1.0' . "rn"; $headers .= "Content-Type: text/html; charset=ISO-8859-1rn"; if ($_POST['Submit']) { if (empty($_POST['Phone'])) { $content = "<html> <head></head> <body> <div class='boldtext'>From:</div> $name <br/> <div class='boldtext'>E-mail:</div> $email <br/><br/> $message <style> .boldtext { font-weight: bold; } </style> </body> </html>"; if (mail ($to, $subject, $content, $from, $headers)) { echo '<div class="boldtext">Your message has been sent. Thank you!</div>'; } else { echo '<div class="messageerror">An error has occurred. Try again later.</div>'; } }
The email client receives the email as plain text instead of HTML formatted though.
Advertisement
Answer
Your email will be like an HTML page as displayed on the WWW. You can use every element the same way.
Something like:
$content = "<html> <head></head> <body> <div class='title'>My Title</div> ... <div class='end'>Best Regards</div> <style> .title { color : blue; } .end { color : green; } </style> </body> </html>";
should work just fine.