By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
438,746 Members | 1,924 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 438,746 IT Pros & Developers. It's quick & easy.

applying stylesheet for a php mail

pradeepjain
100+
P: 563
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
Sep 26 '08 #1
Share this Question
Share on Google+
6 Replies


Markus
Expert 5K+
P: 6,050
You need to give the stylesheet a direct url (http://domain.com/stylesheet.css)
Sep 26 '08 #2

pradeepjain
100+
P: 563
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...
Sep 26 '08 #3

Markus
Expert 5K+
P: 6,050
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.
Sep 26 '08 #4

pradeepjain
100+
P: 563
Why don't you try it and tell me. :)

Cheers.

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

Thanks,
Pradeep
Sep 27 '08 #5

pbmods
Expert 5K+
P: 5,821
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.  
Sep 27 '08 #6

P: 1
@pbmods
this is also not working... plz send me code as soon as posible
Jan 12 '12 #7

Post your reply

Sign in to post your reply or Sign up for a free account.