【问题标题】:yii2 cuts css classes in the emailsyii2 削减电子邮件中的 css 类
【发布时间】:2016-08-03 10:38:40
【问题描述】:

我使用模板发送电子邮件:

         $content='Message';
         Yii::$app->mailer->compose('@app/mail/templates/templ', ['content'=>$content])
        ->setFrom('gorobets.asya@gmail.com')
        ->setTo('nastya.g2410@gmail.com')
        ->setSubject('Message subject')
        ->send();

还有我的模板:

<?php
use yii\helpers\Html;

/* @var $this \yii\web\View view component instance */
/* @var $message \yii\mail\MessageInterface the message being composed */
/* @var $content string main view render result */
?>
<?php $this->beginPage() ?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"   "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
    <meta http-equiv="Content-Type" content="text/html; charset=<?=   Yii::$app->charset ?>" />
    <style type="text/css">
        .footer {
         color: red;
        }
    </style>
    <?php $this->head() ?>
</head>
<body>
<?php $this->beginBody() ?>
<?= $content ?>
<div class="footer">With kind regards </div>
<?php $this->endBody() ?>
</body>
</html>
<?php $this->endPage() ?>

当我阅读我的电子邮件时,我发现 css 类不起作用。类'页脚'也。 我该如何解决这个问题?

【问题讨论】:

    标签: html css email yii2 swiftmailer


    【解决方案1】:

    这不是 Yii 2 的问题。如果不直接应用于元素,大多数电子邮件客户端会忽略 css 样式。

    有一篇很棒的文章 - Using CSS in HTML Emails: The Real Story

    【讨论】:

      猜你喜欢
      • 2021-02-02
      • 1970-01-01
      • 2019-11-19
      • 2013-08-02
      • 1970-01-01
      • 2010-10-15
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多