Answer the question
In order to leave comments, you need to log in
How to remove Swiftmailer settings from config?
Good day. I need to implement my own class to send mail. Is it possible to take out these settings and change them dynamically?
'transport' => [
'class' => 'Swift_SmtpTransport',
'host' => '',
'port' => '',
'username' => ' ',
'password' => '',
'encryption' => 'ssl',
],
Answer the question
In order to leave comments, you need to log in
You take out the config in a separate file where you need:
<?php
return [
'support' => [
'class' => 'yii\swiftmailer\Mailer',
'useFileTransport' => false,
'transport' => [
'class' => 'Swift_SmtpTransport',
'host' => 'mailmail.ru',
'username' => '[email protected]',
'password' => 'c',
'port' => '465',
'encryption' => 'ssl',
],
],
'noReply' => [
'class' => 'yii\swiftmailer\Mailer',
'useFileTransport' => false,
'transport' => [
'class' => 'Swift_SmtpTransport',
'host' => 'mail.mail.ru',
'username' => '[email protected]',
'password' => '',
'port' => '465',
'encryption' => 'ssl',
],
],
];
$mailers = require __DIR__ . '/../components/mailer/config.php';
'components'=> [
...
'supportMailer' => $mailers['support'],
'noreplyMailer' => $mailers['noReply'],
...
]
Yii::$app=>supportMailer ...
Yii::$app=>noreplyMailer...
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question