I have the following code that is very simple and gets information from form fields and mails it off. The issue is that when the email is received using Microsoft Outlook 2003 the message is blank and the actual message that is supposed to be there is an attached HTML file. This, as you can imagine, would be tedious to open every time a message is received.

<?php 
	$recipient = "name@email.com";
	$subject = "Message from ".$_REQUEST['YourName'];
	$headers="From: ".$_REQUEST['YourEmail']."\n";
	$headers.="Content-type: text/html; charset=iso-8859-1";
	$message = "<p>A ".$_REQUEST['EnquiryType']." from ".$_REQUEST['YourName']." has been received</p>
				<b>The message is as follows: </b><p>".$_REQUEST['YourMessage']."</p>
				<p><b>Sender Details</b><br/>Email: ".$_REQUEST['YourEmail']."<br/>Tel: ".$_REQUEST['YourPhone']."</p>
				";
	if(mail($recipient, $subject, $message, $headers))
	{
		header("Location: http://www.blank.co.uk/thanks.html");
	}
	else
	{
		echo "There was an error sending your message. Please contact us via telephone.";
	}
?>

So I'm not sure if there is something wrong with my PHP code or my Outlook setup. Granted I am receiving other HTML messages without it being an attachment.

Any input would be appreciated!

I think you need to end each header with a linefeed and carriage return:

$headers="From: ".$_REQUEST['YourEmail']."\r\n";	
$headers.="Content-type: text/html; charset=iso-8859-1 \r\n";

Maybe your second header is being ignored because it doesn't currently end in a "\r\n".

I tried this and I really hoped it would have been that simple.
Sadly I just tested it and the email came through again with the HTML body text being attached to a blank email with a HTML attachment.

Bugger!

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.