I am wondering how can i style an emailed contact form results. Meaning, when a person fills out my contact form, when the results come to me in an email, I wanted that results to come in a stylistic way.
Here is my contact form, Just a simple form:
<form method="post" action="PHP_Email_Form.php">
<label>First Name: <input type="text" name="First Name" size="30" maxlength="30" />
</label>
<label>Last Name: <input type="text" name="First Name" size="30" maxlength="30" />
</label>
<textarea name="Comments" rows="8" cols="50" style="margin-left:37px" />
</textarea>
<input type="submit" value="submit" />
</form>
My PHP Script:
<?php
$to = 'dew02d@yahoo.com';
$subject = 'Client feed back';
$message= '';
foreach ($_POST as $key => $value)
{
$message .= $key . ': ' . $value . PHP_EOL;
}
mail($to, $subject, $message);
header('Location:/contactThx.htm');
?>
Use HTML tags in your message body, and add a content-type header in your email:
$to = 'dew02d@yahoo.com';
$subject = 'Client feed back';
$message= '';
foreach ($_POST as $key => $value)
{
$message .= '<strong>' . $key . '</strong>' . ': ' . $value . PHP_EOL;
}
$headers = 'Content-type: text/html; charset=iso-8859-1' . "
";
mail($to, $subject, $message, $headers);
header('Location:/contactThx.htm');
First of all you should shift your self to PHPMailer Library. this library will allow you to send stylistic and HTML emails.
Kindly follow the follwing URL that will let you know the way to send a stylistic email into mailbox.
http://www.computersneaker.com/send-email-using-phpmailer/
You can attach images into your email with this tutorial.