Jump to content

Headers in email body


bfinke

Recommended Posts

I've been working on this for hours and its driving me insane.

 

 

<?php
$email = '[email protected]';
$subject = "Test";
$message = "<h2>Hello</h2><p>Second line here</p>";

$headers = 'MIME-Version: 1.0' . "\r\n";
$headers .= 'Content-type: text/html; charset=iso-8859-1' . "\r\n";
$headers .= 'From: [email protected]' . "\r\n" .
'Reply-To: [email protected]' . "\r\n" .
'X-Mailer: PHP/' . phpversion();
$checker = mail($email, $subject, $message, $headers);
?>

 

After sending the email, the headers show up in the body of the email and its all just text, no html like I'm going for.

 

This is the email:

 



Content-type: text/html; charset=iso-8859-1

From: [email protected]
Reply-To: [email protected]
X-Mailer: PHP/4.3.9

<h2>EHLLO</h2><p>this should be on a new line and this is </p>

 

Any help is appreciated very much!

Link to comment
https://forums.phpfreaks.com/topic/138936-headers-in-email-body/
Share on other sites

I'm unsure whats wrong with yours, i use the following.

 

$HTML = your message content/body.

 

 

	$headers = "From: $from\r\n";
$headers .= "MIME-Version: 1.0\r\n";
$boundary = uniqid("HTMLEMAIL");
$headers .= "Content-Type: multipart/alternative;".
				"boundary = $boundary\r\n\r\n";
$headers .= "This is a MIME encoded message.\r\n\r\n";
$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(strip_tags($HTML))); 
$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($HTML)); 

I find it curious too, I changed it too

 


	$subject = "Your spring textbooks";
	$message = "<h2>This is right</h2><p>Yes this is right! $mascot_temp $firstname_temp $userid_temp</p>";

	$headers = 'From: [email protected]' . "\r\n";
	$headers .= "Content-type: text/html";

 

And it's working. But still doesn't seem right to me.

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.