applying stylesheet for a php mail

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • pradeepjain
    Contributor
    • Jul 2007
    • 563

    applying stylesheet for a php mail

    Hii guys,
    i am generating a php mail like this
    [PHP]$message = '
    <html>
    <head>
    <style type="text/css" media="all">@im port "/themes/admitcard.css"; </style>
    <title>Birthd ay 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">Re f=' . $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
    Recognized Expert Expert
    • Jun 2007
    • 6092

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

    Comment

    • pradeepjain
      Contributor
      • Jul 2007
      • 563

      #3
      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...

      Comment

      • Markus
        Recognized Expert Expert
        • Jun 2007
        • 6092

        #4
        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.

        Comment

        • pradeepjain
          Contributor
          • Jul 2007
          • 563

          #5
          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

          Comment

          • pbmods
            Recognized Expert Expert
            • Apr 2007
            • 5821

            #6
            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:

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

            Comment

            • amitmaurya
              New Member
              • Jan 2012
              • 1

              #7
              hey pbmodes

              Originally posted by pbmods
              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:

              [code=html]
              <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dt d">
              <html>
              <body>
              <style type="text/css">
              ...
              </style>
              </body>
              </html>
              [/code]
              this is also not working... plz send me code as soon as posible

              Comment

              Working...