本文整理汇总了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]);
}
}
示例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]);
}
示例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]);
}
}
示例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]);
}
}
示例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']);
}
示例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);
});
}