tags:

views:

29

answers:

3

Hi

I am trying to send a mail with html template. The mail was sent. but i can't find the design there in that mail. How to send the mail with the design.

The mail should exactly look like what i view in my html template.

How to do this? kindly advice.

Thanks in advance.

My code:

$subject = "Hi this is subject";
$email   = "[email protected]";
$message = "<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"&gt;
<html xmlns="http://www.w3.org/1999/xhtml"&gt;
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
<title>Super Qpon </title>
</head>
<link rel="stylesheet" href="../stylesheet/common.css" type="text/css">
<body>

<div class="mainbodycontainer">
<div class="gift">
<div class="gft-top"></div>
<div class="gft-bg">
<div class="">
<h1 class="title">Gift Coupon</h1>
<div class="toppm">
<div class="coupon">
<div class="cop-top"></div>
<div class="cop-bg">
<div>
<table width="165" align="right" border="0" cellpadding="0" cellspacing="0">
<tr>
<td width="81" class="t5">Coupon No :</td>
<td width="84">SQ548555</td>
</tr>
</table>
<div class="spacer"></div>
</div>
<div class="toppm">
<table width="500" border="0" cellpadding="0" cellspacing="0">
<tr>
<td width="99" height="30">From</td>
<td width="15" align="center">:</td>
<td width="386">test</td>
</tr>
<tr>
<td height="30">Amount</td>
<td align="center">:</td>
<td>$560</td>
</tr>
</table>
<div class="spacer"></div>
</div>
<div class="toppm">
<table width="165" align="right" border="0" cellpadding="0" cellspacing="0">
<tr>
<td width="81" class="t5">CODE NO :</td>
<td width="84">SQ548555</td>
</tr>
</table>
</div>
<div class="spacer"></div>
</div>
<div class="cop-btm"></div>
<div class="spacer"></div>
</div>
<div class="spacer"></div>
</div>
<div class="spacer"></div>
</div>
<div class="spacer"></div>
</div>
<div class="gft-btm"></div>
<div class="spacer"></div>
</div>
<div class="spacer"></div>
</div>

</body>
</html>";


$headers  = 'MIME-Version: 1.0' . "\r\n";
$headers .= 'Content-type: text/html; charset=iso-8859-1' . "\r\n";
$headers .= 'From: SuperQpon <[email protected]>' . "\r\n";
mail($email,$subject,$message,$headers );
A: 

Your problem may lie here:

<link rel="stylesheet" href="../stylesheet/common.css" type="text/css">

This stylesheet needs to be linked into the email if you want that to work. The relative path refers to where it lies on your computer/server - which will be inaccesible from the email when received.

EDIT

You can simplify your life a lot by using http://postageapp.com/

Jamie Wong
could u please provide me a solution to do that ? i am bit confused about it. I had give the whole server path where the system contains the style sheet. Is there any other choice ?
Fero
It is possible to include the stylesheet as an attachment, though I don't know how to reference it in the HTML. It can also be supplied inline.
staticsan
Check out postageapp
Jamie Wong
Perhaps putting the CSS in the actual html file would work (in the head section), ie:<style type="text/css">//Your CSS here</style>
Chief17
+1  A: 

It would be more better if you define all your styles in the tag's attributes. like this (style="background-color:#aefd34;").

I faced the similar problem but when I defined the CSS in the style attribute all went fine.

Gaurav Sharma
this solves my issue too. thanks
Fero
@Fero: You're welcome
Gaurav Sharma
A: 

You can use any templating system you like (e.g. Smarty) to produce email content, though you need to be aware that email is not the web, and differences between email clients' HTML rendering are far greater than web browsers. Take a look at www.email-standards.org for more detail on that. I suggest you use a library to send your rendered messages though, such as PHPMailer, SwiftMailer, Zend_Mail etc. To do automated conversion from linked to inline styles (plus critique of email compatibility of your content), take a look at premailer

Synchro