當前位置: 首頁>>代碼示例>>PHP>>正文


PHP UserMailer::mail方法代碼示例

本文整理匯總了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();
     }
 }
開發者ID:JCQS04,項目名稱:myimouto,代碼行數:24,代碼來源:AdminController.php

示例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');
         }
     }
 }
開發者ID:JCQS04,項目名稱:myimouto,代碼行數:38,代碼來源:UserController.php


注:本文中的UserMailer::mail方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。