Jump to content

[SOLVED] Html Emails Using PHP


mme

Recommended Posts

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
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.