Sending email message as html
Posted: Tue Mar 13, 2012 9:15 pm
I have created a process script for a form that is designed to generate an html email for both the user and the client. The email that goes to the client is successful in sending an html email, but I can't figure out how to do the same for the user/recipient. The receipt email includes the html tags. I'm assuming it has something to do with the multiple $headers and where they are located. I have included my sample process script below. Any help is much appreciated. Thank you in advance for the help!
***** PLEASE USE PHP CODE TAG *****
***** PLEASE USE PHP CODE TAG *****
Code: Select all
<?php header("Location: ../contactthank.php");
?>
<?PHP
$field_Type = $_POST['field_Type'];
$field_Service_Provider = $_POST['field_Service_Provider'];
$field_Brand = $_POST['field_Brand'];
$field_Model = htmlspecialchars($_POST['field_Model']);
$field_Size = $_POST['field_Size'];
$field_Accessories = $_POST['field_Accessories'];
$field_Condition = $_POST['field_Condition'];
$field_FirstName = htmlspecialchars($_POST['field_FirstName']);
$field_LastName = htmlspecialchars($_POST['field_LastName']);
$field_Email = $_POST['field_Email'];
$field_ZipCode = (int)$_POST['field_ZipCode'];
$field_Comments = $_POST['field_Comments'];
?>
<?php $reference = (rand(100000000000,99900000000000));
echo $reference;
?>
<?php
$to = "johndoe@mail.com";
$subject = "Cell Phone Form Submission# $reference";
$headers = "From: $field_Email\n";
$message = '<html>
<head>
<title>Cell Phone Form Submission</title>
</head>
<body>
<h1>Thank you for trying us! We will get back to you shortly</h1>
<table border="1">
<tr>
<td>Reference#</td>
<td>' . $reference . '</td>
</tr>
<tr>
<td>I want to</td>
<td><b>Sell</b></td>
</tr>
<tr>
<td>Service Provider</td>
<td>' . $field_Service_Provider . '</td>
</tr>
<tr>
<td>Model</td>
<td>' . $field_Model . '</td>
</tr>
<tr>
<td>Size</td>
<td> ' . $field_Size . '</td>
</tr>
<tr>
<td>Accessories</td>
<td>' . $field_Accessories . '</td>
</tr>
<tr>
<td>Condition</td>
<td>' . $field_Condition . '</td>
</tr>
<tr>
<td>Name</td>
<td>' . $field_FirstName . " " . $field_LastName . '</td>
</tr>
<tr>
<td>Email</td>
<td>' . $field_Email . '</td>
</tr>
<tr>
<td>Zip Code</td>
<td>' . $field_ZipCode . '</td>
</tr>
<tr>
<td>Comments</td>
<td>' . $field_Comments . '</td>
</tr>
</table></body>
</html>
';
$headers = 'MIME-Version: 1.0' . "\r\n";
$headers .= 'Content-type: text/html; charset=iso-8859-1' . "\r\n";
$user = "$field_Email";
$usersubject = "Cell Phone Form Submission# $reference";
$userheaders = "From: johndoe@mail.com\n";
$usermessage = '<html>
<head>
<title>Cell Phone Form Submission</title>
</head>
<body>
<h1>Thank you for trying us! We will get back to you shortly</h1>
<table border="1">
<tr>
<td>Reference#</td>
<td>' . $reference . '</td>
</tr>
<tr>
<td>I want to</td>
<td><b>Sell</b></td>
</tr>
<tr>
<td>Service Provider</td>
<td>' . $field_Service_Provider . '</td>
</tr>
<tr>
<td>Model</td>
<td>' . $field_Model . '</td>
</tr>
<tr>
<td>Size</td>
<td> ' . $field_Size . '</td>
</tr>
<tr>
<td>Accessories</td>
<td>' . $field_Accessories . '</td>
</tr>
<tr>
<td>Condition</td>
<td>' . $field_Condition . '</td>
</tr>
<tr>
<td>Name</td>
<td>' . $field_FirstName . " " . $field_LastName . '</td>
</tr>
<tr>
<td>Email</td>
<td>' . $field_Email . '</td>
</tr>
<tr>
<td>Zip Code</td>
<td>' . $field_ZipCode . '</td>
</tr>
<tr>
<td>Comments</td>
<td>' . $field_Comments . '</td>
</tr>
</table></body>
</html>
';
mail($to,$subject,$message,$headers);
mail($user,$usersubject,$usermessage,$userheaders,$headers);
?>