I was wondering if there was a way to create a PHP Contact Form where
the email that is sent can be formatted for html. So that for example
the email that is received is formatted like an html page where it
contains a background, images & formatted text. I can't figure out how
to do this. I tried something like "$MESSAGE_BODY .= "<img src="images/
bgaccess.jpg" width="800" height="653" />;" to insert an image but I
received an error. I would think there was a way to format the email.
Can anyone help?
I have the following code so far:
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>Untitled Document</title>
</head>
<body>
<?php
if ($_POST["email"]<>'') {
$ToEmail = '...@email.com';
$EmailSubject = 'Site contact form ';
$mailheader = "From: ".$_POST["email"]."\r\n";
$mailheader .= "Reply-To: ".$_POST["email"]."\r\n";
$mailheader .= "Content-type: text/html; charset=iso-8859-1\r\n";
$MESSAGE_BODY = "<img src="images/bgaccess.jpg" width="800"
height="653" />";
$MESSAGE_BODY .= "Name: ".$_POST["name"]."<br>";
$MESSAGE_BODY .= "Email: ".$_POST["email"]."<br>";
$MESSAGE_BODY .= "Comment: ".nl2br($_POST["comment"])."<br>";
mail($ToEmail, $EmailSubject, $MESSAGE_BODY, $mailheader) or die
("Failure");
?>
Your message was sent
<?php
} else {
?>
<form action="test.php" method="post">
<table width="400" border="0" cellspacing="2" cellpadding="0">
<tr>
<td width="29%" class="bodytext">Your name:</td>
<td width="71%"><input name="name" type="text" id="name" size="32"></
td>
</tr>
<tr>
<td class="bodytext">Email address:</td>
<td><input name="email" type="text" id="email" size="32"></td>
</tr>
<tr>
<td class="bodytext">Comment:</td>
<td><textarea name="comment" cols="45" rows="6" id="comment"
class="bodytext"></textarea></td>
</tr>
<tr>
<td class="bodytext"> </td>
<td align="left" valign="top"><input type="submit" name="Submit"
value="Send"></td>
</tr>
</table>
</form>
<?php
};
?>
</body>
</html>