mme Posted December 3, 2008 Share Posted December 3, 2008 Hi I am trying to send a html email with dynamic text however I get an email filled with html code. in my index.php $msg_m="This is some dynamic text<br />this is amother line of random text"; require('email_template.php'); $ArrayLNTargets = array("\r\n", "\n\r", "\n", "\r", "\t"); $msg = str_replace($ArrayLNTargets, '', $msg); $header = "From: \"$site_name\" <$from_email>\n"; $header .= "Sender: $from_email\n"; Mail($addr, "$site_name Invitation", $msg, $header); in email_template.php <?php $msg='<html> <head> <META HTTP-EQUIV="Content-Type" CONTENT="text/html;charset=iso-8859-1"> <style type="text/css"> TD{FONT-FAMILY:Verdana,Tahoma,Arial,"Sans Serif";FONT-SIZE:10pt} BODY{FONT-FAMILY:Verdana,Tahoma,Arial,"Sans Serif";FONT-SIZE:10pt} a {color:#333333; text-decoration:underline; } a:hover { color:#666666; } .style2 { font-size: 8pt; font-style: italic; } .style7 { font-size: 12pt; font-weight: bold; } </style> <!-- HTML-FORMATTED MESSAGE BELOW The remainder of this message is in HTML format for use by email clients that can properly display it. If you are seeing this message, it is because your email client cannot properly display HTML. You can ignore the HTML code you will see below. --> </head> <body bgColor="#eeeeee"> <table cellSpacing="1" cellPadding="0" width="700" bgColor="#fff" border="0" align="center"> <tr> <td><img src="http://mydomain.com/email_header.jpg" alt="Header" border="0"></td> </tr> <tr> <td bgcolor="white"> <table cellSpacing="0" cellPadding="15" width="100%"><tr><td><hr size="0" color="#CCCCCC"> <table cellspacing="0" cellpadding="10" width="100%"><tr><td><table cellspacing="0" cellpadding="10" width="100%"> <tr> <td> <p><span class="style2">This is an automated email</span><br> <br> <span class="style7">A Title</span></p> <p>' .$msg_m. '<br> </strong></a></p> </td> </tr></table></td></tr></table> <hr size="0" color="#CCCCCC"> <center> <br><small>© <a href="#l">Site name</a></small><br> </center></td></tr> </table></td></tr></table> </body></html>'; ?> Thanks Link to comment https://forums.phpfreaks.com/topic/135283-solved-html-emails-using-php/ Share on other sites More sharing options...
dclamp Posted December 3, 2008 Share Posted December 3, 2008 you need to set the content type in the Header: Content-type: text/html; Link to comment https://forums.phpfreaks.com/topic/135283-solved-html-emails-using-php/#findComment-704651 Share on other sites More sharing options...
mme Posted December 3, 2008 Author Share Posted December 3, 2008 How would I do that and what would I put in it? Thanks Link to comment https://forums.phpfreaks.com/topic/135283-solved-html-emails-using-php/#findComment-704683 Share on other sites More sharing options...
haku Posted December 3, 2008 Share Posted December 3, 2008 <?php header("Content-type: text/html"); ?> Link to comment https://forums.phpfreaks.com/topic/135283-solved-html-emails-using-php/#findComment-704713 Share on other sites More sharing options...
dclamp Posted December 3, 2008 Share Posted December 3, 2008 <?php header("Content-type: text/html"); ?> And in the header for the mail function. You have $header = "..."; put content type there as well. Link to comment https://forums.phpfreaks.com/topic/135283-solved-html-emails-using-php/#findComment-704718 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.