开发者

Is it possible to send an html email with PHP that inludes CSS decoration without using MIME?

I need to send an email with PHP that is decorated with CSS. My code as of right now works just fine for sending an html email. But, I can't seem to find out how to decorate it.

Here is my code:

//Message
    $message =  "<html>
                    <head>
                        <style type='text/css'>
                            #show {border:solid 1px #c4c4c4; background-color:#f0f0f0; width:400px;}
                            #red {color:#F02311}
                            #header {font-size:14px}
                            p {color:#090127}
                        </style>
                        <title>
                            Red-line
                        </title>
                    </head>
                    <body>
                        <div id='show'>
                            <a id='red' href='http://www.thered-line.com'>The Red-line</a>
                        </div>

                        <p>
                            Hi $first_name, 
                        </p> 

                        <p>
                            Your Red-line account is almost complete. To finish, go to <a href='www.thered-line.com'>The Red-line</a> and enter开发者_开发知识库 your eight digit confirmation code.
                        </p> 

                        <p>
                            Your confirmation code is: <b>$code</b>
                        </p> 

                        <p>
                            Sincerely,
                        </p> <br />

                        <p>
                            The Red-line Operator
                        </p> 
                    </body>
                </html>";


I haven't used the PHP libraries, but when I created mail with .Net I never included elements like <head> or <body>. I don't think html mail messages are designed to be complete Html documents.

I would recommend that you included your <style> element, then go right into your content like this:

<style type='text/css'>
        #show {border:solid 1px #c4c4c4; background-color:#f0f0f0; width:400px;}
        #red {color:#F02311}
        #header {font-size:14px}
        p {color:#090127}
</style>    
<div id='show'>
       <a id='red' href='http://www.thered-line.com'>The Red-line</a>
</div>

 <p>
      Hi $first_name, 
 </p> 

 <p>
      Your Red-line account is almost complete. To finish, go to <a href='www.thered-line.com'>The Red-line</a> and enter your eight digit confirmation code.
 </p> 

 <p>
       Your confirmation code is: <b>$code</b>
 </p> 

 <p>
       Sincerely,
 </p> <br />

 <p>
       The Red-line Operator
 </p> 


I'd recommend taking a look into http://www.email-standards.org/ . Several major webmail-clients remove or modify a bunch of important html elements - including <style ...>.

Inline-styles prevent your mailing from getting stripped off style completly. From the mentioned page you can propably assemble your own set of supported /needed style attributes.

0

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜