本文整理汇总了PHP中MailForm::validate方法的典型用法代码示例。如果您正苦于以下问题:PHP MailForm::validate方法的具体用法?PHP MailForm::validate怎么用?PHP MailForm::validate使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类MailForm
的用法示例。
在下文中一共展示了MailForm::validate方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: actionMail
public function actionMail($id)
{
$model = new MailForm();
if (isset(\Yii::$app->request->post()['MailForm'])) {
$model->load(\Yii::$app->request->post()['MailForm']);
if ($model->validate()) {
$class = new $this->module->userClass();
$criteria = new CDbCriteria();
$criteria->condition = $this->module->userIdColumn . ' = :id';
$criteria->params = array(':id' => \Yii::$app->user->identity->id);
$user = $class::find()->find($criteria);
$from = $user->getAttribute($this->module->userMailColumn);
$criteria->params = array(':id' => $model->member_id);
$user = $class::find()->find($criteria);
$to = $user->getAttribute($this->module->userMailColumn);
$name = BbiiMember::find(\Yii::$app->user->identity->id)->member_name;
$name = ' = ?UTF-8?B?' . base64_encode($name) . '? = ';
$subject = ' = ?UTF-8?B?' . base64_encode($model->subject) . '? = ';
$sendto = $model->member_name . " <{$to}>";
$headers = "From: {$name} <{$from}>\r\n" . "To: {$sendto}\r\n" . "Date: " . date(DATE_RFC2822) . "\r\n" . "Reply-To: {$from}\r\n" . "Message-ID: <" . uniqid('', true) . "@bbii.forum>\r\n" . "MIME-Version: 1.0\r\n" . "Content-type: text/html; charset = UTF-8";
mail($sendto, $subject, $model->body, $headers);
\Yii::$app->session->addFlash('notice', Yii::t('BbiiModule.bbii', 'You have sent an e-mail to {member_name}.', array('{member_name}' => $model->member_name)));
return \Yii::$app->response->redirect(array('forum/view', 'id' => $model->member_id));
}
} else {
$model->member_id = $id;
$model->member_name = BbiiMember::find($id)->member_name;
}
return $this->render('mail', array('model' => $model));
}