YiiMailer:无法查看“;html";电子邮件
我正在使用YiiMailer服务,包括以下内容YiiMailer:无法查看“;html";电子邮件,html,email,yii,Html,Email,Yii,我正在使用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
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();
}
}
我正在使用以下模板发送电子邮件>
不知道为什么在电子邮件中,我收到的是纯文本而不是html格式的电子邮件。。虽然在模板中,我指的是一个正确的css文件和正确的路径。
如果我遗漏了什么,有人能告诉我吗?
谢谢YiiMailer扩展了PHPMailer,因此看看PHPMailer类,我们应该能够执行以下操作来实现html电子邮件:
$mail->Body("Sample Message");
$mail->IsHtml(true);
$mail->setData(
array(
'name' => 'John Doe',
'description' => 'Contact form'
));