Выносишь конфиг в отдельный файл куда тебе нужно:
<?php
return [
'support' => [
'class' => 'yii\swiftmailer\Mailer',
'useFileTransport' => false,
'transport' => [
'class' => 'Swift_SmtpTransport',
'host' => 'mailmail.ru',
'username' => 'support@mail.ru',
'password' => 'c',
'port' => '465',
'encryption' => 'ssl',
],
],
'noReply' => [
'class' => 'yii\swiftmailer\Mailer',
'useFileTransport' => false,
'transport' => [
'class' => 'Swift_SmtpTransport',
'host' => 'mail.mail.ru',
'username' => 'noreply@mail.ru',
'password' => '',
'port' => '465',
'encryption' => 'ssl',
],
],
];
И в web.php
$mailers = require __DIR__ . '/../components/mailer/config.php';
'components'=> [
...
'supportMailer' => $mailers['support'],
'noreplyMailer' => $mailers['noReply'],
...
]
Вызываешь:
Yii::$app=>supportMailer ...
Yii::$app=>noreplyMailer...