Html yii2在电子邮件中剪切css类

Html yii2在电子邮件中剪切css类,html,css,email,yii2,swiftmailer,Html,Css,Email,Yii2,Swiftmailer,我使用以下模板发送电子邮件: $content='Message'; Yii::$app->mailer->compose('@app/mail/templates/templ', ['content'=>$content]) ->setFrom('gorobets.asya@gmail.com') ->setTo('nastya.g2410@gmail.com') ->set

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

         $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() ?>
和我的模板:

         $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() ?>


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


关于这方面有很多文章-

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

关于这一点,有一篇很棒的文章-