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();
See also: MessageInterface
Since: 2.0
Author: Paul Klimov (klimov.paul@gmail.com)
Exemple #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();
 }
Exemple #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();
 }
 /**
  * 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();
     }
 }