\Yii::$app->mailer->htmlLayout = false;
$res = \Yii::$app->mailer->compose('/mail/mail', [
'title' => 'hello'
])->setFrom('test1@test.com')
->setTo('test2@test.com')
->setSubject('测试邮件')
->send();
var_dump($res);
'mailer' => [
'class' => 'yii\swiftmailer\Mailer',
'transport' => [
'class' => 'Swift_SmtpTransport',
'host' => 'smtp.qq.com',
'username' => 'test1@qq.com',
'password' => 'xxxxxxxxxx',
'port' => '465',
'encryption' => 'ssl',
],
'messageConfig'=>[
'charset'=>'UTF-8',
'from'=>['test1@test.com'=>'display name']
],
],