Example #1
0
 public function actionSend()
 {
     $mailer = new Mailer();
     $mails = $mailer->find("status=1")->asArray()->all();
     foreach ($mails as $value) {
         Yii::$app->mailer->compose()->setFrom($value["from"])->setTo($value["to"])->setCc($value["cc"])->setBcc($value["bcc"])->setSubject($value["subject"])->setHtmlBody($value["message"])->send();
     }
 }
Example #2
0
 /**
  * Creates data provider instance with search query applied
  *
  * @param array $params
  *
  * @return ActiveDataProvider
  */
 public function search($params)
 {
     $query = Mailer::find();
     $dataProvider = new ActiveDataProvider(['query' => $query]);
     $this->load($params);
     if (!$this->validate()) {
         // uncomment the following line if you do not want to return any records when validation fails
         // $query->where('0=1');
         return $dataProvider;
     }
     $query->andFilterWhere(['id' => $this->id, 'status' => $this->status, 'created_date' => $this->created_date, 'modified_date' => $this->modified_date, 'send_date' => $this->send_date, 'created_by' => $this->created_by, 'modified_by' => $this->modified_by]);
     $query->andFilterWhere(['like', 'to', $this->to])->andFilterWhere(['like', 'from', $this->from])->andFilterWhere(['like', 'cc', $this->cc])->andFilterWhere(['like', 'bcc', $this->bcc])->andFilterWhere(['like', 'message', $this->message])->andFilterWhere(['like', 'error_message', $this->error_message])->andFilterWhere(['like', 'subject', $this->subject]);
     return $dataProvider;
 }