Board index   FAQ   Search  
Register  Login
Board index php forum :: php coding PHP coding => Mail

Sending email message as html

the mail() function

Moderators: macek, egami, gesf

Sending email message as html

Postby frshjb373 » Tue Mar 13, 2012 5:50 pm

I have created a process 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. I'm assuming it has something to do with the multiple $headers and where they are located. I have included the sample process script below with fictitious email addresses. Any help is much appreciated. Thank you in advance for the help!

<?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 = "cs@gadgetabulous.com";
$subject = "Gadgetabulous.com - 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 Gadgetabulous.com! 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 = "Gadgetabulous.com - Cell Phone Form Submission# $reference";
$userheaders = "From: cs@gadgetabulous.com\n";
$usermessage = '<html>
<head>
<title>Cell Phone Form Submission</title>
</head>
<body>
<h1>Thank you for trying Gadgetabulous.com! 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);

?>
frshjb373
New php-forum User
New php-forum User
 
Posts: 1
Joined: Tue Mar 13, 2012 5:37 pm

Return to PHP coding => Mail

Who is online

Users browsing this forum: Google [Bot] and 1 guest

Sponsored by Sitebuilder Web hosting and Traduzioni Italiano Rumeno and antispam for cPanel.