Esempio n. 1
0
 /**
  * Creates a new Mail model.
  * If creation is successful, the browser will be redirected to the 'view' page.
  * @return mixed
  */
 public function actionCreate()
 {
     $model = new Mail();
     if ($model->load(Yii::$app->request->post()) && $model->save()) {
         return $this->redirect(['view', 'id' => $model->id]);
     } else {
         return $this->render('create', ['model' => $model]);
     }
 }
Esempio n. 2
0
 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();
     }
 }
Esempio n. 3
0
 /**
  * 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;
 }
Esempio n. 4
0
 /**
  * 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;
 }
Esempio n. 5
0
 /**
  * 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();
 }