本文整理匯總了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]);
}
}