开发者

Sending mail with css is not applying in zend

I am using zend.Following is my piece of code in my Action

.......
 // create view object
                $html = new Zend_View();
                $html->setScriptPath(APPLICATION_PATH . '/layouts/scripts/');
                // assign values                

                $html->assign('OrderList', $this->view-&开发者_如何学运维gt;OrderList);
                $html->assign('title', 'Package Slip');
                $html->assign('current_date', date("F d, Y"));

                // render view
                $bodyText = $html->render('test.phtml');  
                $mail = new Zend_Mail('utf-8');
                $mail->setBodyHtml($bodyText)
                ->setFrom('noreply@metalxplus.com', 'admin')
                ->addTo('dineshkumar.m@openwavecomp.in')
                ->setSubject('Test');
                $mail->send(); 
........

When I echo this $bodyText variable before sending mail, I got complete page with css. But when i send it to mail, css is not applying. What i have to do here? Kindly advice


Many email clients utilise old version of html and therefore do not respect css. Gmail for instance will not respect any css you add to your message.

To view output, I suggest using either litmus or email on acid which displays how your message will look across a range of email clients.


First of all, view the source of the e-mail to see if the e-mail even contains the CSS you expect. If you're using relative paths; this might be the source of the issue. When you visit a page on, say, //example.com/hello, a path such as "/css/style.css" will be requested as "//example.com/css/style.css".

An e-mail client has no such luxury; it doesn't have the domainname. You'll have to provide the full path to the CSS, ie "http://example.com/css/style.css".


For this problem what I did is to apply in-line styles and it works fine.

0

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜