Jump to content

[SOLVED] HTML emails with PHP mail function


axiom82

Recommended Posts

Okay so I've read a few articles about PHP/HTML emails and can't seem to get my emails to display as HTML in Microsoft Outlook.  I believe the issue is in the headers but I've included the mime version and content type which I thought was the only requirements to format the text as HTML.

 

Any ideas on what might be wrong with my code?  Thanks!

 

<?php

$email['sender']['name'] = 'John Smith';
$email['sender']['address'] = '[email protected]';

$email['recipient']['name'] = 'Jane Smith';
$email['recipient']['address'] = '[email protected]';

$email['subject'] = 'Registration Confirmation';

$email['message'] = '

	<style type="text/css">
		.msg
		{
			color:black;
			font-family:arial, helvetica;
			font-size:10pt;
		}
		.msg span
		{
			display:block;
			margin-bottom:16px;
		}
		.msg p
		{
			line-height:1.5em;
			text-indent:0.5in;
		}
		.msg hr
		{
			color:gray;
			height:1px;
			margin-bottom:16px;
		}	
		.msg div
		{
			padding-left:0.5in;
			padding-bottom:16px;
		}
		.msg div span
		{
			margin-bottom:8px;
		}
		.msg div span a
		{
			color:blue;
		}
	</style>
	<div class="msg">
		<span>' . $email['recipient']['name'] . ',</span>
		<p>Thank you for registering...etc, etc, etc...</p>	
	</div>

';

$email['headers']  = "From: {$email['sender']['name']} <{$email['sender']['address']}>\n";
$email['headers'] .= "Reply-To: <{$email['sender']['address']}>\n";
$email['headers'] .= "Return-Path: <{$email['sender']['address']}>\n";
$email['headers'] .= "X-Sender: <{$email['sender']['address']}>\n";
$email['headers'] .= "X-Mailer: PHP/" . phpversion() . "\n";
$email['headers'] .= "X-Priority: 1\n";
$email['headers'] .= "MIME-Version: 1.0\n";
$email['headers'] .= "Content-Type: text/html; charset=iso-8859-1\n";

mail ($email['recipient']['address'], $email['subject'], $email['message'], $email['headers']);

?>

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.