本文整理汇总了PHP中ContactForm::sendEmail方法的典型用法代码示例。如果您正苦于以下问题:PHP ContactForm::sendEmail方法的具体用法?PHP ContactForm::sendEmail怎么用?PHP ContactForm::sendEmail使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类ContactForm
的用法示例。
在下文中一共展示了ContactForm::sendEmail方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: 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]);
}
}
示例2: actionContact
public function actionContact($id)
{
$contactform = new ContactForm();
$model = $this->loadModel($id);
if ($model->status == 'complete') {
Yii::app()->user->setFlash('error', 'Sorry, this posting is complete and you can no longer contact the seller.');
$this->redirect(array('/post/view', 'id' => $model->id));
}
if (isset($_POST['ContactForm'])) {
$contactform->attributes = $_POST['ContactForm'];
if ($contactform->validate()) {
if ($contactform->sendEmail($model)) {
Yii::app()->user->setFlash('success', 'Email sent successfully.');
$this->redirect(array('/post/view', 'id' => $model->id));
} else {
Yii::app()->user->setFlash('error', 'Error sending email. Please contact us.');
}
} else {
$contactform->verifyCode = '';
}
}
$this->render('contact', array('model' => $model, 'contactform' => $contactform));
}
示例3: 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]);
}
}