A mailer should mainly support creating and sending [[MessageInterface|mail messages]]. It should also support composition of the message body through the view rendering mechanism. For example, php Yii::$app->mailer->compose('contact/html', ['contactForm' => $form]) ->setFrom('from@domain.com') ->setTo($form->email) ->setSubject($form->subject) ->send();
См. также: MessageInterface
С версии: 2.0
Автор: Paul Klimov (klimov.paul@gmail.com)
Пример #1
0
 /**
  * Send email logic.
  *
  * @param MailerInterface $mailer
  * @param array $address
  */
 protected function sendEmail(MailerInterface $mailer, $address)
 {
     $message = $mailer->compose();
     $message->setTextBody(file_get_contents($this->_output))->setSubject($this->getEmailSubject())->setTo($address);
     $message->send();
 }
Пример #2
0
 /**
  * E-mail the output of the event to the recipients.
  *
  * @param MailerInterface $mailer
  * @param  array $addresses
  */
 protected function emailOutput(MailerInterface $mailer, $addresses)
 {
     $mailer->compose()->setTextBody(file_get_contents($this->_output))->setSubject($this->getEmailSubject())->setTo($addresses)->send();
 }
Пример #3
0
 /**
  * E-mail the output of the event to the recipients.
  *
  * @param MailerInterface $mailer
  * @param  array $addresses
  */
 protected function emailOutput(MailerInterface $mailer, $addresses)
 {
     $textBody = file_get_contents($this->_output);
     if (trim($textBody) != '') {
         $mailer->compose()->setTextBody($textBody)->setSubject($this->getEmailSubject())->setFrom($this->_fromAddress)->setTo($addresses)->send();
     }
 }