我正在使用以下
的YiiMailer服务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('admin@website.com', '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 :(得分:0)
YiiMailer扩展了PHPMailer,所以在查看PHPMailer类时,我们应该能够执行以下操作来实现html电子邮件:
$mail->Body("Sample Message");
$mail->IsHtml(true);
$mail->setData(
array(
'name' => 'John Doe',
'description' => 'Contact form'
));