Exemplo n.º 1
0
 /**
  * Renders the contact page
  * @return string
  */
 public function actionContact()
 {
     $model = new ContactForm();
     if ($model->load(Yii::$app->request->post()) && $model->sendEmail(Yii::$app->params['adminEmail'])) {
         Yii::$app->session->setFlash('contactFormSubmitted');
         return $this->refresh();
     } else {
         return $this->render('contact', ['model' => $model]);
     }
 }
Exemplo n.º 2
0
 /**
  * @param null|\app\core\admpages\models\Page $modelPage
  * @return string|\yii\web\Response
  */
 public function actionContact($modelPage = null)
 {
     $model = new ContactForm();
     if ($model->load(Yii::$app->request->post()) && $model->validate()) {
         if ($model->sendEmail()) {
             Yii::$app->session->setFlash('success', Yii::t("app/contacts", "Thank you for contacting us. We will respond to you as soon as possible.", ['dot' => false]));
             return $this->refresh();
         }
         Yii::$app->session->setFlash('error', Yii::t("app/contacts", "There was an error sending email.", ['dot' => false]));
     }
     return $this->render('contact', ['model' => $model, 'modelPage' => $modelPage]);
 }
 /**
  * Displays contact page.
  *
  * @return mixed
  */
 public function actionContact()
 {
     $model = new ContactForm();
     if ($model->load(Yii::$app->request->post()) && $model->validate()) {
         if ($model->sendEmail(Yii::$app->params['adminEmail'])) {
             Yii::$app->session->setFlash('success', 'Thank you for contacting us. We will respond to you as soon as possible.');
         } else {
             Yii::$app->session->setFlash('error', 'There was an error sending email.');
         }
         return $this->refresh();
     } else {
         return $this->render('contact', ['model' => $model]);
     }
 }
Exemplo n.º 4
0
 public function actionContact()
 {
     $model = new ContactForm();
     if ($model->load(Yii::$app->request->post()) && $model->validate()) {
         if ($model->sendEmail(Yii::$app->params['adminEmail'])) {
             Yii::$app->session->setFlash('success', '感谢您与我们联系。 我们将尽快回复您.');
         } else {
             Yii::$app->session->setFlash('error', '送电子邮件时出现错误。');
         }
         return $this->refresh();
     } else {
         return $this->render('contact', ['model' => $model]);
     }
 }
Exemplo n.º 5
0
 public function actionContact()
 {
     $model = new ContactForm();
     if ($model->load(Yii::$app->request->post()) && $model->validate()) {
         if ($model->sendEmail(Yii::$app->params['adminEmail'])) {
             Yii::$app->session->setFlash('success', 'Dank u voor uw bericht. Wij zullen zo spoedig mogelijk contact met u opnemen.');
         } else {
             Yii::$app->session->setFlash('error', 'Er ging iets fout met het versturen');
         }
         return $this->refresh();
     } else {
         return $this->render('contact', ['model' => $model, 'page' => 'page-contact']);
     }
     //return $this->render('contact', ['page' => 'page-contact']);
 }
Exemplo n.º 6
0
 public function testContact()
 {
     $model = new ContactForm();
     $model->attributes = ['name' => 'Tester', 'email' => '*****@*****.**', 'subject' => 'very important letter subject', 'body' => 'body of current message'];
     $model->sendEmail('*****@*****.**');
     $this->specify('email should be send', function () {
         expect('email file should exist', file_exists($this->getMessageFile()))->true();
     });
     $this->specify('message should contain correct data', function () use($model) {
         $emailMessage = file_get_contents($this->getMessageFile());
         expect('email should contain user name', $emailMessage)->contains($model->name);
         expect('email should contain sender email', $emailMessage)->contains($model->email);
         expect('email should contain subject', $emailMessage)->contains($model->subject);
         expect('email should contain body', $emailMessage)->contains($model->body);
     });
 }