HTML tags show in email

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
User avatar
aceconcepts
DevNet Resident
Posts: 1424
Joined: Mon Feb 06, 2006 11:26 am
Location: London

HTML tags show in email

Post by aceconcepts »

Hi,

I have finally got my mail() working. However, when I receive the email all the HTML tags show.

Below is the code used to generate the email.

Please note:

$guestMsg is just plain text from a textbox.

$guestByTel is a boolean value used to determine whether the user selected a checkbox element.

Code: Select all

$to = "nick@q2q.co.uk";
		$subject = "Message from Q2Q web site";
		$message="<html><body>";
		$message.= "<div>" . $guestMsg . "</div>";
		//CHECK GUEST CONTACT PREFERENCE
			if($guestByTel==1)
			{
				$message .= "<br /><br /><div><span style=\"font-weight:bold;\">" . $guestName . " has made a request to be contacted by telephone.</span></div>";
			}
		$message.="</body></html>";
		$from = $guestEmail;
		$headers = "MIME-Version: 1.0\r\n";
		$headers .= "Content-type: text/html; charset=ISO-8859-15";
		$headers .= "Content-Transfer-Encoding: 7bit";
		$headers = "From: {$from}";
		$headers .= "Reply-To: {$from}";
		$headers .= "Return-Path: {$from}";
		mail($to,$subject,$message,$headers,"-f $from");
User avatar
feyd
Neighborhood Spidermoddy
Posts: 31559
Joined: Mon Mar 29, 2004 3:24 pm
Location: Bothell, Washington, USA

Post by feyd »

You're missing carriage returns in your headers.. ;)
Post Reply