當前位置: 首頁>>代碼示例>>PHP>>正文


PHP ContactForm::sendEmail方法代碼示例

本文整理匯總了PHP中app\models\ContactForm::sendEmail方法的典型用法代碼示例。如果您正苦於以下問題:PHP ContactForm::sendEmail方法的具體用法?PHP ContactForm::sendEmail怎麽用?PHP ContactForm::sendEmail使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在app\models\ContactForm的用法示例。


在下文中一共展示了ContactForm::sendEmail方法的6個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的PHP代碼示例。

示例1: actionContact

 /**
  * 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]);
     }
 }
開發者ID:Quexer69,項目名稱:app,代碼行數:14,代碼來源:SiteController.php

示例2: actionContact

 /**
  * @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]);
 }
開發者ID:pavlinter,項目名稱:yii2-app-core,代碼行數:16,代碼來源:PagesController.php

示例3: actionContact

 /**
  * 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]);
     }
 }
開發者ID:nanodirijabl,項目名稱:garrulous-meow,代碼行數:19,代碼來源:SiteController.php

示例4: actionContact

 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]);
     }
 }
開發者ID:hehbhehb,項目名稱:hongsong,代碼行數:14,代碼來源:SiteController.php

示例5: actionContact

 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']);
 }
開發者ID:amavis442,項目名稱:vpjuristen,代碼行數:15,代碼來源:SiteController.php

示例6: testContact

 public function testContact()
 {
     $model = new ContactForm();
     $model->attributes = ['name' => 'Tester', 'email' => 'tester@example.com', 'subject' => 'very important letter subject', 'body' => 'body of current message'];
     $model->sendEmail('admin@example.com');
     $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);
     });
 }
開發者ID:Humanized,項目名稱:viajero,代碼行數:16,代碼來源:ContactFormTest.php


注:本文中的app\models\ContactForm::sendEmail方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。