Exemple #1
0
 /**
  * @return bool
  * @throws InvalidConfigException
  */
 public function process()
 {
     $mailer = $this->getMailer();
     $items = QueueMails::find()->where(['!=', 'status', QueueMails::STATUS_SENT])->limit($this->mailsPerRound)->orderBy('id DESC')->all();
     $valid = true;
     foreach ($items as $item) {
         $valid = $valid && $item->send($mailer);
     }
     return $valid;
 }
Exemple #2
0
 /**
  * Sends this email message.
  * @param MailerInterface $mailer the mailer that should be used to send this message.
  * If null, the "mail" application component will be used instead.
  * @return boolean whether this message is sent successfully.
  */
 public function send(MailerInterface $mailer = null)
 {
     $data['options'] = $this->options;
     $data['methods'] = $this->methods;
     $model = new QueueMails();
     $model->data = serialize($data);
     $model->email = $this->getTo();
     $model->subject = $this->getSubject();
     $model->user_id = Yii::$app->user->isGuest ? '' : Yii::$app->user->id;
     return $model->save();
 }