本文整理匯總了PHP中UserMailer::mail方法的典型用法代碼示例。如果您正苦於以下問題:PHP UserMailer::mail方法的具體用法?PHP UserMailer::mail怎麽用?PHP UserMailer::mail使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類UserMailer
的用法示例。
在下文中一共展示了UserMailer::mail方法的2個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的PHP代碼示例。
示例1: resetPassword
public function resetPassword()
{
if ($this->request()->isPost()) {
$user = User::find_by_name($this->params()->user['name']);
if ($user) {
$new_password = $user->reset_password();
$this->notice('Password reset to ' . $new_password);
if ($user->email) {
// try {
UserMailer::mail('new_password', [$user, $new_password])->deliver();
// } catch (\Exception $e) {
// $this->respond_to_success("Specified user's email address was invalid",
// ['#reset_password'], ['api' => ['result' => 'invalid-email']]);
// return;
// }
}
} else {
$this->notice('That account does not exist');
$this->redirectTo('#reset_password');
}
} else {
$this->user = new User();
}
}
示例2: resetPassword
public function resetPassword()
{
$this->set_title('Reset Password');
if ($this->request()->isPost()) {
$this->user = User::where(['name' => $this->params()->user['name']])->first();
if (!$this->user) {
$this->respond_to_error("That account does not exist", '#reset_password', ['api' => ['result' => "unknown-user"]]);
return;
}
if (!$this->user->email) {
$this->respond_to_error("You never supplied an email address, therefore you cannot have your password automatically reset", '#login', ['api' => ['result' => "no-email"]]);
return;
}
if ($this->user->email != $this->params()->user['email']) {
$this->respond_to_error("That is not the email address you supplied", '#login', ['api' => ['result' => "wrong-email"]]);
return;
}
# iTODO:
try {
// User.transaction do
# If the email is invalid, abort the password reset
$new_password = $this->user->reset_password();
UserMailer::mail('new_password', [$this->user, $new_password])->deliver();
$this->respond_to_success("Password reset. Check your email in a few minutes.", '#login', ['api' => ['result' => "success"]]);
return;
// end
} catch (Exception $e) {
// rescue Net::SMTPSyntaxError, Net::SMTPFatalError
$this->respond_to_success("Your email address was invalid", '#login', ['api' => ['result' => "invalid-email"]]);
return;
}
} else {
$this->user = new User();
if ($this->params()->format and $this->params()->format != 'html') {
$this->redirectTo('root');
}
}
}