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(); } }
/** * 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; }
public function actionSignup() { if (!\Yii::$app->user->isGuest) { return $this->goHome(); } $model = new User(); $model->generateConfirmToken(); if ($model->load(Yii::$app->request->post()) && $model->save()) { if ($model->validate()) { if (Mailer::send_confirmation($model)) { Yii::$app->getSession()->setFlash('success', 'Your account has been created successfully,We sent you a confirmation mail, Please check your mail & create your password'); } return $this->goHome(); } } return $this->render('signup', ['model' => $model]); }
/** * Finds the Mailer model based on its primary key value. * If the model is not found, a 404 HTTP exception will be thrown. * @param integer $id * @return Mailer the loaded model * @throws NotFoundHttpException if the model cannot be found */ protected function findModel($id) { if (($model = Mailer::findOne($id)) !== null) { return $model; } else { throw new NotFoundHttpException('The requested page does not exist.'); } }