Esempio n. 1
0
 public static function queueDispatch()
 {
     $mails = MailQueue::find()->where(['=', 'success', 0])->andWhere(['<', 'attempts', 4])->all();
     //var_dump($mails)       ;
     foreach ($mails as $mail) {
         MailQueue::sendMail($mail);
     }
     return true;
 }
 /**
  * Creates data provider instance with search query applied
  *
  * @param array $params
  *
  * @return ActiveDataProvider
  */
 public function search($params)
 {
     $query = MailQueue::find();
     $dataProvider = new ActiveDataProvider(['query' => $query]);
     $this->load($params);
     if (!$this->validate()) {
         // uncomment the following line if you do not want to any records when validation fails
         // $query->where('0=1');
         return $dataProvider;
     }
     $query->andFilterWhere(['id' => $this->id]);
     $query->andFilterWhere(['like', 'from_name', $this->from_name]);
     $query->andFilterWhere(['like', 'from_email', $this->from_email]);
     $query->andFilterWhere(['like', 'to_name', $this->to_name]);
     $query->andFilterWhere(['like', 'to_email', $this->to_email]);
     $query->andFilterWhere(['like', 'subject', $this->subject]);
     $query->andFilterWhere(['like', 'success', $this->success]);
     return $dataProvider;
 }
 private function GetStatistics()
 {
     $statistics['contacts'] = \common\models\MailQueue::find()->where(['type' => \common\enum\EmailType::CONTACT])->count();
     $statistics['users'] = \common\models\User::find()->where(['status' => \common\enum\UserStatus::ACTIVE])->count();
     return $statistics;
 }