Connecting Tech Pros Worldwide Forums | Help | Site Map

applying stylesheet for a php mail

pradeepjain's Avatar
Needs Regular Fix
 
Join Date: Jul 2007
Location: India
Posts: 407
#1: Sep 26 '08
Hii guys,
i am generating a php mail like this
[PHP]$message = '
<html>
<head>
<style type="text/css" media="all">@import "/themes/admitcard.css";</style>
<title>Birthday Reminders for August</title>
</head>
<body>
<div id="textcontent">
)<img src="/logo.jpg"></img></h3>
<table align="center" width="100%" border="1" cellspacing="2" cellpadding="2" id="img1">
<tr>
<td align="left">Ref=' . $ID . '</td>
</tr>
</table>
<table align="center" width="100%" border="1" cellspacing="2" cellpadding="2" id="img1">
<tr row span="20">
<td>Name</td>
<td>:</td>
<td><b>' . $name . '</b></td>
<td colspan=2><img src="http://dsfsdfsdf/pic.php?Id=528"></img></td>
</tr>
<tr>
<td>Address</td>
<td>:</td>
<td><p>'. $address .'</p></td>
</tr>
</table>

</body>
</html> ';

// To send HTML mail, the Content-type header must be set
$headers = 'MIME-Version: 1.0' . "\r\n";
$headers .= 'Content-type: text/html; charset=iso-8859-1' . "\r\n";

// Additional headers
//$headers .= 'To:'. $email . "\r\n";
$headers .= 'From: webmaster <webmaster@test.com>' . "\r\n";
$headers .= 'Cc: test@tst.com' . "\r\n";

// Mail it



$ok=mail($to, $subject, $message, $headers);

[/PHP]


this mail is getting delivered properly.but i want to apply css to this html..the stylesheet line that i have added is taking no effect..Can any one help.


thanks,
Pradeep
Markus's Avatar
Moderator
 
Join Date: Jun 2007
Location: York, England, with wolves.
Posts: 4,936
#2: Sep 26 '08

re: applying stylesheet for a php mail


You need to give the stylesheet a direct url (http://domain.com/stylesheet.css)
pradeepjain's Avatar
Needs Regular Fix
 
Join Date: Jul 2007
Location: India
Posts: 407
#3: Sep 26 '08

re: applying stylesheet for a php mail


Quote:

Originally Posted by Markus

You need to give the stylesheet a direct url (http://domain.com/stylesheet.css)

oh ok....the relative path will not work here..srry for that.Is there no other way to do it.such as writing the style in head itself...
Markus's Avatar
Moderator
 
Join Date: Jun 2007
Location: York, England, with wolves.
Posts: 4,936
#4: Sep 26 '08

re: applying stylesheet for a php mail


Quote:

Originally Posted by pradeepjain

oh ok....the relative path will not work here..srry for that.Is there no other way to do it.such as writing the style in head itself...

Why don't you try it and tell me. :)

Cheers.
pradeepjain's Avatar
Needs Regular Fix
 
Join Date: Jul 2007
Location: India
Posts: 407
#5: Sep 27 '08

re: applying stylesheet for a php mail


Quote:

Originally Posted by Markus

Why don't you try it and tell me. :)

Cheers.


I tried it did not work so asked u. :(

Thanks,
Pradeep
pbmods's Avatar
Site Moderator
 
Join Date: Apr 2007
Location: Texas
Posts: 5,435
#6: Sep 27 '08

re: applying stylesheet for a php mail


Heya, Pradeep.

For best results, you should put your CSS directly into your HTML. GMail ignores stuff in the <head>, so even though it violates HTML standards, you need to put your <style> tags in the <body> of your email:

Expand|Select|Wrap|Line Numbers
  1. <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
  2. <html>
  3.   <body>
  4.     <style type="text/css">
  5.       ...
  6.     </style>
  7.   </body>
  8. </html>
  9.  
Reply