yii2 配置多邮件账号发送邮件

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来配置多账号

你可能感兴趣的:(php爬坑之路)