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