我尝试的是'viewPath' => '@frontend/views/mail'
。由于它已设置为此文件,因此仍在搜索layouts/html
。如何覆盖它?我试图将htmlLayout
属性保留为空,但它搜索.../frontend/views/mail/.php
。如何禁用(如果可以这样说)htmlLayout
属性?我的代码如下:
'mailer' => [
'class' => 'yii\swiftmailer\Mailer',
'htmlLayout' => '',
'viewPath' => '@frontend/views/mail',
'transport' => [
'class' => 'Swift_SmtpTransport',
'host' => 'localhost',
'username' => Yii::$app->params['adminEmail'],
'password' => Yii::$app->params['adminEmailPass'],
'port' => '587',
'encryption' => 'tls',
],
],
发送邮件,例如:
Yii::$app->mailer->compose('contact',[
'title' => 'test'
])
->setFrom(Yii::$app->params['adminEmail'])
->setTo($model->email)
->setSubject(Yii::t('app', 'Successfully sent message')." - ".Yii::$app->name)
->send();