How to send email using swiftMailer in Yii2?

Hi all. I can't completely understand how all the same to use the extension swiftMailer in Yii2. Judging by the fact that questions on this topic I have not found a trivial task, but to understand it I couldn't.

There are examples that do not describe more in detail the whole cycle of sending the letter or I something don't understand :(

Installation
return [
//....
 'components' => [
......
 'mail' => [
 'class' => 'yii\swiftmailer\Mailer',
 'transport' => [
 'class' => 'Swift_SmtpTransport',
 'host' => 'localhost',
 'username' => 'username',
 'password' => 'password',
 'port' => '587',
 'encryption' => 'tls',
],
],
]
];


Sending
Yii::$app->mail->compose()
->setTo($toEmail)
 ->setFrom([$this->email => $this->name])
->setSubject($this->subject)
->setTextBody($this->body)
 ->send();


From all this it is unclear how I, for example, to connect to the mail biz.mail.ru. On the hosting mail server is not.

'host' => 'localhost',
'username' => 'username',
'password' => 'password',
'port' => '587',

Here
host: smtp.mail.ru, username: account@domain.ru, password: password of account@domain.ru

Tell me, what am I doing wrong.

PS Domain MX record set up, DKIM, SPF added.
UPD1: can't send email in this way. The page is long loaded, and then falls off on a time-out: screenshot.ru/upload/images/2014/07/28/mama_bus_de...
September 26th 19 at 06:59
3 answers
September 26th 19 at 07:01
The answer is of course outdated, but many can be useful. Here's how you can get a log of the whole process of sending a message, and there it becomes clear what the problem is.

$mailer = Yii::$app->get('mailer');
$message = $mailer->compose() ... ;
$logger = new Swift_Plugins_Loggers_ArrayLogger();
$mailer->getSwiftMailer()->registerPlugin(new Swift_Plugins_LoggerPlugin($logger));
if (!$message->send()) {
 echo $logger->dump();
}
prescribed logger dam empty - jewell76 commented on September 26th 19 at 07:04
: Use var_dump() - Rub commented on September 26th 19 at 07:07
: Yes, still empty - look in the folder the log it seems everything sends but it is such a feeling that the error in the config file - here's a look at my config

'class' => 'yii\swiftmailer\Mailer',
// 'useFileTransport' => false,
'transport' => [
'class' => 'Swift_SmtpTransport',
'host' => 'localhost',
'username' => 'max@localhost',
'password' => '12345',
'port' => '587',
'encryption' => 'tls',
],
], - jewell76 commented on September 26th 19 at 07:10
: And I doubt that with localhost even go mail. There you have the mail server up? - Rub commented on September 26th 19 at 07:13
of course - just mail() sends - jewell76 commented on September 26th 19 at 07:16
September 26th 19 at 07:03
'host' => 'smtp.mail.ru',
'username' => 'account@domain.ru',
'password' => 'password of account@domain.ru',
'port' => '587',

obviously
www.yiiframework.com/wiki/656/how-to-send-emails-u...
Yes, do exactly that. The page is long loaded, and then falls off on a time-out. - jewell76 commented on September 26th 19 at 07:06
screenshot.ru/upload/images/2014/07/28/mama_bus_de... - Rub commented on September 26th 19 at 07:09
September 26th 19 at 07:05
About smtp.mail.ru. 465 port for SSL, 587 TLS.
Plus address ->setFrom([$this->email => $this->name]) must match the 'username' => 'account@domain.ru'.

Find more questions by tags PHPYii