2016-08-03 7 views
-1

내가 템플릿을 사용하여 이메일을 보내 이메일에 CSS 클래스를 절단 :yii2는

  $content='Message'; 
     Yii::$app->mailer->compose('@app/mail/templates/templ', ['content'=>$content]) 
     ->setFrom('[email protected]') 
     ->setTo('[email protected]') 
     ->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 클래스를 볼 수 있습니다. 클래스 '바닥 글'도. 이 문제를 어떻게 해결할 수 있습니까?

답변

1

이것은 Yii 2 호가 아닙니다. 대부분의 이메일 클라이언트는 요소에 직접 적용되지 않으면 CSS 스타일을 무시합니다.

그것에 대해 좋은 기사가있다 - Using CSS in HTML Emails: The Real Story

+0

감사합니다, 나는 그것을 읽을 것이다는 –