use yii\swiftmailer\Mailer;
$config = [
'class' => 'Swift_SmtpTransport',
'host' => 'your host',
'username' => 'your email',
'password' => 'password',
'port' => 'port',
];
$mail = new Mailer;
$mail->setTransport($config);
$mail->messageConfig = [
'charset' => 'UTF-8',
'from' => [$config['username'] => 'xxxx'],
];
$mail = $mail->compose('@common/mail/' . $view, $data);
$mail->setTo($toMail);
$mail->setSubject('subject');
$mail->send()
通过直接调用 yii\swiftmailer\Mailer来配置多账号