开发者

php mail and multiple css classes do not work?

I can't seem to get multiple css classes working with php's mail, I've gotten inline styles to work just fine but when I try to associate classes with elements it's a no go..

Yes, I know there are other options that are probably开发者_JAVA技巧 better than php's mail. Yes, the classes are local and not from an external style sheet.

Only 1 class will show up out of the two specified and it's always the first one.

If I put class="class1 class2" class1 shows, if I put class="class2 class1" class 2 shows.

What's going on?

Here is my test mail.

$msg = '
        <html>
        <head>
        <style type="text/css">
        .class1{background-color:red;}
        .class2{color:blue;}
        </style>
        </head>
        <body>
        <div class="class2 class1">this is a test</div>
        </body>
        </html>';

        $headers  = 'MIME-Version: 1.0' . "\r\n";
        $headers .= 'Content-type: text/html; charset=iso-8859-1' . "\r\n";  

        @mail($to, $sub, $msg, $headers);


The PHP mail() function simply sends the text you give it. You can check whether it is working by looking at the raw source of the email in your email client application. If it is all there, then the mail function is working (and I would be shocked if it wans't).

Your issue is probably that your mail client does not support your css. Mail clients generally handle only very simple styling, so you may want to rethink your email layout.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜