public function actionAdmin() { $model = new Mail(); //$model->unsetAttributes(); // clear any default values $model->load(Yii::$app->request->get()); //$model->attributes = $_GET['Mail']; return $this->render('admin', array('model' => $model)); }
public function generateEmailForgotPassword() { if (!empty($emailTo = $this->email)) { $mail = new Mail(); $mail->to = $emailTo; $mail->subject = Yii::t('app', 'Information from {store_name}', ['store_name' => Property::getPropertyValue('store_name', '')]); $mail->body = StoreUtils::renderView('//mail/_destination_forgot_password', ['model' => $this]); $mail->save(); } }
/** * Sends an email to the specified email address using the information collected by this model. * @param string $email the target email address * @return boolean whether the model passes validation */ public function contact($email) { if ($this->validate()) { $mail = new Mail(); $mail->subject = $this->subject; $mail->body = StoreUtils::renderView('//mail/_contact', ['model' => $this]); $mail->to = $email; $mail->save(); return true; } return false; }
/** * Sends an email to the specified email address using the information collected by this model. * @param string $email the target email address * @return boolean whether the model passes validation */ public function contact($email) { if ($this->validate()) { $mail = new Mail(); $mail->subject = Yii::t('app', 'Comment received on {store}', ['store' => Property::getPropertyValue('store_name', '')]); $mail->body = StoreUtils::renderView('//mail/_comment', ['model' => $this]); $mail->to = $email; $mail->save(); return true; } return false; }
private function send_success_reg_email(User $user) { $emails = \App\Models\Mail::actives(); return Mail::send('emails.new_user', ['user' => $user], function ($message) use($emails) { $message->to($emails)->from('*****@*****.**')->subject('Новый пользователь'); }); }
/** * Will write log to database * @param boolean $result * @param MessageInterface $message */ public function createLog($result, $message) { $mail = new Mail(); $mail->estado = $result ? Mail::IS_SENT : Mail::IS_NOT_SENT; $mail->created_at = time(); $mail->controller = \Yii::$app->controller->id; $mail->action = \Yii::$app->controller->action->id; $temp = []; //store emails as string foreach ($message->getTo() as $email => $name) { $temp[] = $email; } $mail->emails = implode(', ', $temp); $mail->body = $message->toString(); $mail->save(); }
public function getAll() { $collection = Mail::all(); $collection->each(function ($model) use($collection) { $model = $this->completeModel($model); }); return $collection; }
/** * Creates data provider instance with search query applied * * @param array $params * * @return ActiveDataProvider */ public function search($params) { $query = Mail::find(); // add conditions that should always apply here $dataProvider = new ActiveDataProvider(['query' => $query, 'pagination' => ['pageSize' => 50], 'sort' => ['defaultOrder' => ['id' => SORT_DESC]]]); $this->load($params); return $dataProvider; }
private function send_new_order_email(Order $order) { $emails = \App\Models\Mail::actives(); $order_products = OrderProduct::where('order_id', $order->id)->get(); return Mail::send('emails.new_order', ['order' => $order, 'order_products' => $order_products], function ($message) use($emails) { $message->to($emails)->from('*****@*****.**')->subject('Новый заказ'); }); }
public function actionIndex() { Yii::error("RCJ - Esto entro aqui"); /** @var Mail[] $list */ $list = Mail::find()->where('status < :ss and created <= :date', [':ss' => Mail::STATUS_ERROR_FATAL, ':date' => date('Y-m-d H:i:s')])->all(); Yii::error("RCJ - encontro: " . count($list)); print "Procesing: " . count($list) . " mails\n"; foreach ($list as $mail) { $this->send($mail, Yii::$app->params['adminEmail']); } }
public function checkOutNotifyMail($log_id, $user, $checkout_at, $expected_checkin, $note) { $data['log_id'] = $log_id; $data['eula'] = $this->getEula(); $data['first_name'] = $user->first_name; $data['item_name'] = $this->showAssetName(); $data['checkout_date'] = $checkout_at; $data['expected_checkin'] = $expected_checkin; $data['item_tag'] = $this->asset_tag; $data['note'] = $note; $data['item_serial'] = $this->serial; $data['require_acceptance'] = $this->requireAcceptance(); if (($this->requireAcceptance() == '1' || $this->getEula()) && !config('app.lock_passwords')) { \Mail::send('emails.accept-asset', $data, function ($m) use($user) { $m->to($user->email, $user->first_name . ' ' . $user->last_name); $m->subject('Confirm asset delivery'); }); } }
/** * Finds the Mail model based on its primary key value. * If the model is not found, a 404 HTTP exception will be thrown. * @param integer $id * @return Mail the loaded model * @throws NotFoundHttpException if the model cannot be found */ protected function findModel($id) { if (($model = Mail::findOne($id)) !== null) { return $model; } else { throw new NotFoundHttpException('The requested page does not exist.'); } }
public static function mailDoc($model) { $file = PrintDoc::pdfDoc($model); $temp = MailTemplate::find()->where(['entity_type' => 'app\\models\\Docs', 'entity_id' => $model->doctype])->one(); if (!$temp) { $temp = new MailTemplate(); } $temp->templateRplc($model); $mail = new Mail(); $mail->to = $model->account->email; $mail->bcc = $temp->bcc; $mail->files = $file->id; $mail->subject = $temp->subject; $mail->body = $temp->body; $mail->send(); return true; }
public function actionRewrite($email_id, $subject, $receiver, $text, $check_user) { $model = new Mail(); $message = true; $session = Yii::$app->session; //$check_users=Users::find()->where(['permission'=>2])->asArray()->all(); // print_r($check_users); if ($model->load(Yii::$app->request->post())) { //粘贴部分 $mailaccount = Setting::find()->one(); $sendhost = $mailaccount->sendhost; $username = $mailaccount->username; $user = $mailaccount->user; $password = $mailaccount->password; error_reporting(E_ALL ^ E_WARNING); $request = Yii::$app->request; $body = $request->post(); $to = $model->receiver; $subject = $model->subject; $model->file = UploadedFile::getInstance($model, 'file'); //error_reporting(E_ALL^E_WARNING); // $request = Yii::$app->request; //$body = $request->post(); //$to=$model->receiver; // $text=$model->text; // $subject=$model->subject; // $body = $model->body; //print_r($model); //粘贴部分 if ($model->file != null) { $filename = $model->file->name; $encode = mb_detect_encoding($filename, array("ASCII", "UTF-8", "GBK", "GB2312")); if ($encode == "EUC-CN") { $encode = "GB2312"; } if ($encode != "GBK") { $filename = iconv($encode, "GBK//IGNORE", $filename); } //echo $filename."before save"."</br>"; if ($model->file->saveAs('../attachment/sendattachment/' . $filename)) { $mail = new sendmail(); //新建发送 $mail->setServer($sendhost, $user, $password); $mail->setFrom($username); $mail->setReceiver("{$to}"); $mail->setMailInfo($subject, $body['body'], '../attachment/sendattachment/' . $filename); $message = true; //插入check表 //$check_user=$_POST['check_user']; if ($check_user != NULL) { //更新sent邮件列表 $sent_email = SentEmail::findOne($email_id); $sent_email->subject = $subject; $sent_email->receiver = $to; $sent_email->text = $body['body']; $sent_email->attachment = '../attachment/sendattachment/' . $filename . ';'; //$sent_email->sender=$username; //$sent_email->user_id=$session['user_id']; $sent_email->save(); $ck = Check::find()->where(['email_id' => $email_id])->one(); //$check->user_id=$session['user_id']; $ck->check_status = 0; $ck->save(); return $this->redirect('?r=site/checkself&user_id=' . $session['user_id'] . '&check_status=0'); } else { if (!$mail->sendMail()) { $message = false; return $this->render('rewrite', ['model' => $model, 'subject' => $subject, 'receiver' => $receiver, 'text' => $text, 'check_users' => $check_users]); } //$time=date("Y-m-d H:i:s",time()); $session = Yii::$app->session; $sent_email = new SentEmail(); $sent_email->subject = $subject; $sent_email->receiver = $to; $sent_email->text = $body['body']; $sent_email->attachment = '../attachment/sendattachment/' . $filename . ';'; $sent_email->sender = $username; $sent_email->user_id = $session['user_id']; $sent_email->save(); return $this->redirect('?r=site/sent&user_id=' . $session['user_id']); } } } else { $mail = new sendmail(); //新建发送 $mail->setServer($sendhost, $user, $password); $mail->setFrom($username); $mail->setReceiver("{$to}"); $mail->setMailInfo($subject, $body['body'], ""); //插入已发送列表 //插入check表 //$check_user=$_POST['check_user']; if ($check_user != NULL) { //$time=date("Y-m-d H:i:s",time()); $sent_email = SentEmail::findOne($email_id); $sent_email->subject = $subject; $sent_email->receiver = $to; $sent_email->text = $body['body']; //$sent_email->attachment='../attachment/sendattachment/'.$filename.';'; //$sent_email->sender=$username; //$sent_email->user_id=$session['user_id']; $sent_email->save(); $ck = Check::find()->where(['email_id' => $email_id])->one(); //$check->user_id=$session['user_id']; $ck->check_status = 0; $ck->save(); //print_r($check['user_id']); return $this->redirect('?r=site/checkself&user_id=' . $session['user_id'] . '&check_status=0'); } else { if (!$mail->sendMail()) { $message = false; return $this->render('rewrite', ['model' => $model, 'subject' => $subject, 'receiver' => $receiver, 'text' => $text, 'check_user' => $check_user]); } //$time=date("Y-m-d H:i:s",time()); $session = Yii::$app->session; $sent_email = new SentEmail(); $sent_email->subject = $subject; $sent_email->receiver = $to; $sent_email->text = $body['body']; //$sent_email->attachment='../attachment/sendattachment/'.$filename.';'; $sent_email->sender = $username; $sent_email->user_id = $session['user_id']; $sent_email->save(); return $this->redirect('?r=site/sent&user_id=' . $session['user_id']); } } } else { return $this->render('rewrite', ['model' => $model, 'subject' => $subject, 'receiver' => $receiver, 'text' => $text, 'check_user' => $check_user]); } }
public static function sendEmail($email) { Mail::send('emails.newsletter_subscription', $data = array(), function ($message) use($email) { $message->to($email)->subject("Thank you for subscribing to FeatherQ's Newsletters"); }); }
/** * Core sending functions */ public static function sendEmail($email, $template, $subject, $data = array()) { Mail::send($template, $data, function ($message) use($email, $subject) { $message->subject($subject); $message->to($email); }); }