Quantcast
Channel: PHP Freaks: PHP Help
Viewing all articles
Browse latest Browse all 13200

php mail - plain text and html

$
0
0

Hi Guys

 

I am trying to setup an email template that contains both a html and plain text version in one.

 

What follows is a simplified version but what I want to do is simply have both versions in an email template and then run a str_replace which will populate the template's place holders with the relevant data before sending - this is why I want everything in a single file. But before I get to that point I simply need to get the email working - however at present when I run the code below I just get  blank output in the email body.

 

If anyone could propose a reason why this is happening it would be appreciated.

 

Incidentally I realise the mime boundary isn't ideal - this is just for testing.

 

<?php

$headers  = "MIME-Version: 1.0\n";
$headers .= "Content-Type: multipart/related; boundary=\"boundaryMarker\"\n";
$headers .= "Content-Transfer-Encoding: 7bit\n";

$body = "

	--boundaryMarker\n	
	Content-Type: text/plain; charset=\"charset=us-ascii\" \n
	Content-Transfer-Encoding: 7bit\n\n
	
		THIS IS PLAIN TEXT EMAIL
		
		\n\n
		
	--boundaryMarker\n	
	
	\n\n
	
	Content-Type: text/html; charset=ISO-8859-1\n
	Content-Transfer-Encoding: 7bit\n\n
	
	
	<h1>THIS IS HTML VERSION</h1>
	
	\n\n
	
	--boundaryMarker--\n	

";


$to      = 'MyEmail@Myemail.com';
$subject = 'This is a test message';

mail($to, $subject, $body, $headers);

 


Viewing all articles
Browse latest Browse all 13200

Trending Articles