applying stylesheet for a php mail – PHP

  php

Q(Question):

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

A(Answer):

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

A(Answer):

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…

A(Answer):

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.

A(Answer):

Why don’t you try it and tell me. 🙂

Cheers.

I tried it did not work so asked u. 🙁

Thanks,
Pradeep

A(Answer):

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:


<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html>
<body>
<style type="text/css">
...
</style>
</body>
</html>

A(Answer):

@pbmods

this is also not working… plz send me code as soon as posible

LEAVE A COMMENT