2014-12-26 69 views
0

我使用YiiMailer服務具有以下YiiMailer:無法查看「HTML」電子郵件

eturn array(
'viewPath' => 'webroot.themes.abound.views.mail', 
'layoutPath' => 'webroot.themes.abound.views.layouts.mail', 
'baseDirPath' => 'webroot.images.mail', //note: 'webroot' alias in console apps may not be the same as in web apps 
'savePath' => 'webroot.assets.mail', 
'testMode' => false, 
'layout' => 'mail', // name of the file 
'CharSet' => 'iso-8859-1', 
'AltBody' => Yii::t('YiiMailer', 'You need an HTML capable viewer to read this message.'), 
'language' => array(
    'authenticate' => Yii::t('YiiMailer', 'SMTP Error: Could not authenticate.'), 
    'connect_host' => Yii::t('YiiMailer', 'SMTP Error: Could not connect to SMTP host.'), 
    'data_not_accepted' => Yii::t('YiiMailer', 'SMTP Error: Data not accepted.'), 
    'empty_message' => Yii::t('YiiMailer', 'Message body empty'), 
    'encoding' => Yii::t('YiiMailer', 'Unknown encoding: '), 
    'execute' => Yii::t('YiiMailer', 'Could not execute: '), 
    'file_access' => Yii::t('YiiMailer', 'Could not access file: '), 
    'file_open' => Yii::t('YiiMailer', 'File Error: Could not open file: '), 
    'from_failed' => Yii::t('YiiMailer', 'The following From address failed: '), 
    'instantiate' => Yii::t('YiiMailer', 'Could not instantiate mail function.'), 
    'invalid_address' => Yii::t('YiiMailer', 'Invalid address'), 
    'mailer_not_supported' => Yii::t('YiiMailer', ' mailer is not supported.'), 
    'provide_address' => Yii::t('YiiMailer', 'You must provide at least one recipient email address.'), 
    'recipients_failed' => Yii::t('YiiMailer', 'SMTP Error: The following recipients failed: '), 
    'signing' => Yii::t('YiiMailer', 'Signing Error: '), 
    'smtp_connect_failed' => Yii::t('YiiMailer', 'SMTP Connect() failed.'), 
    'smtp_error' => Yii::t('YiiMailer', 'SMTP server error: '), 
    'variable_set' => Yii::t('YiiMailer', 'Cannot set or reset variable: ') 
), 

$mail = new YiiMailer(); 
     $mail->setView('contact'); 
     $mail->setData(
         array( 'message' => "Sample Message", 
           'name' => 'John Doe', 
           'description' => 'Contact form' 
          )); 
     $mail->setFrom('[email protected]', 'website'); 
     $mail->setTo($_POST['logEmail']); 
     $mail->setLayout('basic'); 
     $mail->setSubject('Mail subject'); 
     if ($mail->send()) { 
      Yii::app()->user->setFlash('contact','Thank you for contacting us. We will respond to you as soon as possible.'); 
     } else { 
      Yii::app()->user->setFlash('error','Error while sending email: '.$mail->getError()); 
     } 
     /////// Email Code over 

     $model->Email=$_POST['logEmail']; 
     $model->Password=$_POST['logPassword']; 
     if($model->validate() && $model->login()) 
     { 
      //echo "" 
     } 
     else 
     { 
      echo "User Name or Password seems to be incorrect, Try again"; 
      exit(); 
     } 
    } 

我使用下面的模板來發送電子郵件>http://zurb.com/playground/responsive-email-templates

不知道爲什麼在電子郵件中,我接收純文本,而不是HTML豐富的電子郵件..雖然在模板中,我指的是正確的路徑正確的CSS文件。 任何人都可以讓我知道如果我錯過了什麼嗎? 感謝

回答

0

YiiMailer延伸PHPMailer的,所以看的PHPMailer類,我們應該能做到以下幾點,以實現HTML電子郵件:

$mail->Body("Sample Message"); 
$mail->IsHtml(true); 
$mail->setData(
    array(
      'name' => 'John Doe', 
      'description' => 'Contact form' 
     ));