Here it is described that in order to send several messages at a time (several recipients), you must use the following code:
$messages = []; foreach ($users as $user) { $messages[] = Yii::$app->mailer->compose() // ... ->setTo($user->email); } Yii::$app->mailer->sendMultiple($messages);
The question is: why is it needed and why was it developed, if the simplest and most common
Yii::$app->mailer->compose() ->setFrom('from@domain.com') ->setTo(['mail1@site.ru,mail2@site.ru,mail3@site.ru,']) ->setSubject('Тема сообщения') ->setTextBody('Текст сообщения') ->setHtmlBody('<b>текст сообщения в формате HTML</b>') ->send();
sends all messages?