Jump to content

html emails


Space Cowboy

Recommended Posts

<?php
//--SETS UP THE EMAIL LAYOUT WITH VARIABLES IN PLACE
$administrator="$email";
$subject="test mails";
$message.="$textarea\n";

//--SENDS THE EMAIL
mail($administrator,$subject,$message,"From:[email protected]");
?>

 

Hello, this is the code im using to send out an email (the variable $textarea" comes from a form (text area) just submitted).

 

The emails are sending out, however if I send out html, the actual code shows up in the email rather than the visual style the HTML should render. How do I change this?

Link to comment
https://forums.phpfreaks.com/topic/64811-html-emails/
Share on other sites

<?php
//add From: header 
$headers = "From: [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("$abstract")); 

//send message 
mail("$email", "An HTML Message", "", $headers); 
?>

 

OK, ive adapted this code and I think im getting somewhere.

 

The email is being recieved in HTML, things like the bold/strong tag and H1/h2 tags are being picked up, but its stripping all style.

 

If I send something with a table like this:

 

 <table width="680" border="4" align="center" cellpadding="0" cellspacing="0" bordercolor="#257690" bgcolor="#257690">

 

its being stripped and when recieved its coming out as just

 

<table>

 

 

arrrghhhhhhhhhhhhh!

Link to comment
https://forums.phpfreaks.com/topic/64811-html-emails/#findComment-323391
Share on other sites

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.