Hello,
I'm trying to send an HTML formatted email when a user submits a form on my website. I've tested the email with several webmail applications and also with Apple's Mail.app and it works perfectly. The only place I'm having trouble is with MS Outlook (both 2003 and 2007).
When the email is viewed in Outlook, I see the raw HTML code preceded with the following header info - "Content-type:text/html;charset=iso-8859-1".
I've searched online and on this board for common solutions and have tried them all, including:
- Remove the <html><head> and <title> tags. (I've tried this, but still no luck)
- Make sure that the HTML is W3C Validated. (I've succesfully validated it)
- Make sure that Outlook is set to view HTML content, and not convert to plain text. (I've made sure that my settings are correct).
I've even directly copied and pasted other people's code, that they claim is working for them, and I still have no luck in Outlook, so there must be something I'm missing here.
I'm pulling my hair out on this one! Can anyone please shed some light on this for me or find a problem in my code below?
Thanks!
Dave
<?php
// REQUEST CONTACT INFO
$fname = $_REQUEST['fname'];
$lname = $_REQUEST['lname'];
$company = $_REQUEST['company'];
$phone = $_REQUEST['phone'];
$email = $_REQUEST['email'] ;
$address1 = $_REQUEST['address1'];
$address2 = $_REQUEST['address2'];
$city = $_REQUEST['city'];
$state = $_REQUEST['state'];
$zip = $_REQUEST['zip'];
// REQUEST PHONE INFO
$stock1 = $_REQUEST['phone1stock'];
$barcode1 = $_REQUEST['phone1barcode'];
// ASSEMBLE HEADERS
$to = "email@mydomain.com";
$subject = "Subject Here";
$headers = "From: $email\r\n";
$headers .= "Reply-To: $email\r\n";
$headers .= "MIME-Version: 1.0" . "\r\n";
$headers .= "Content-type:text/html;charset=iso-8859-1" . "\r\n";
// E-MAIL MESSAGE
$message = "
<!DOCTYPE html PUBLIC \"-//W3C//DTD XHTML 1.0 Transitional//EN\" \"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd\">
<html xmlns=\"http://www.w3.org/1999/xhtml\">
<head>
<meta http-equiv=\"Content-Type\" content=\"text/html; charset=UTF-8\" />
<title>Form Confirmation</title>
</head>
<body>
<h2>Contact Information</h2>
<p>
<strong>Name:</strong> $fname $lname <br />
<strong>Company:</strong> $company <br />
<strong>Phone:</strong> $phone <br />
<strong>Email:</strong> $email <br />
<strong>Address 1:</strong> $address1 <br />
<strong>Address 2:</strong> $address2 <br />
<strong>City:</strong> $city <br />
<strong>State:</strong> $state <br />
<strong>Zip:</strong> $zip <br />
</p>
<h2>Phone Information</h2>
<h3 style=\"padding:0px; margin:10px 0px 4px 0px;\">Phone 1</h3>
<strong>Stock No:</strong> $stock1 <br />
<strong>Barcode No:</strong> $barcode1 <br />
</body>
</html>
";
?>