• Notice regarding image hosts and attachments. See here.

php sending HTML emails

Associate
Joined
23 Mar 2005
Posts
967
Location
Colchester, Essex
Ok, I'm trying to send an HTML email.. So far I have this...

Code:
	//add From: header 
	$headers = "From: Email App <[email protected]>\r\n"; 

	//specify MIME version 1.0 
	$headers .= "MIME-Version: 1.0\r\n"; 

	//unique boundary 
	$boundary = uniqid("HTMLDEMO"); 

	//tell e-mail client this e-mail contains//alternate versions 
	$headers .= "Content-Type: multipart/alternative; boundary = $boundary\r\n\r\n"; 

	//message to people with clients who don't 
	//understand MIME 
	$headers .= "This is a MIME encoded message.\r\n\r\n"; 

	//plain text version of message 
	$headers .= "--$boundary\r\n" . 
	   "Content-Type: text/plain; charset=ISO-8859-1\r\n" . 
	   "Content-Transfer-Encoding: base64\r\n\r\n"; 
	$headers .= chunk_split(base64_encode("This is the plain text version!")); 

	//HTML version of message 
	$headers .= "--$boundary\r\n" . 
	   "Content-Type: text/html; charset=ISO-8859-1\r\n" . 
	   "Content-Transfer-Encoding: base64\r\n\r\n"; 
	$headers .= chunk_split(base64_encode("This the <b>HTML</b> version!")); 

	mail("[email protected]", "An HTML Message", "", $headers);

For some reason the HTML works in most email readers (horde/outlook/thunderbird) however, googlemail is letting me down. (I can't have that obv).

I know googlemail accepts html emails, and comparing the headers I still can't find the difference??

Any ideas?
 
Yeah I went for the mailer class in the end and used the SMTP mail method.

God knows why the php was giving me issues.

Oh well!
 
Back
Top Bottom