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


PHP Application::mailer方法代碼示例

本文整理匯總了PHP中Pagekit\Application::mailer方法的典型用法代碼示例。如果您正苦於以下問題:PHP Application::mailer方法的具體用法?PHP Application::mailer怎麽用?PHP Application::mailer使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在Pagekit\Application的用法示例。


在下文中一共展示了Application::mailer方法的5個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的PHP代碼示例。

示例1: requestAction

 /**
  * @Request({"email": "string"})
  */
 public function requestAction($email)
 {
     try {
         if (App::user()->isAuthenticated()) {
             return App::redirect();
         }
         if (!App::csrf()->validate()) {
             throw new Exception(__('Invalid token. Please try again.'));
         }
         if (empty($email)) {
             throw new Exception(__('Enter a valid email address.'));
         }
         if (!($user = User::findByEmail($email))) {
             throw new Exception(__('Unknown email address.'));
         }
         if ($user->isBlocked()) {
             throw new Exception(__('Your account has not been activated or is blocked.'));
         }
         $user->activation = App::get('auth.random')->generateString(32);
         $url = App::url('@user/resetpassword/confirm', ['user' => $user->username, 'key' => $user->activation], 0);
         try {
             $mail = App::mailer()->create();
             $mail->setTo($user->email)->setSubject(__('Reset password for %site%.', ['%site%' => App::module('system/site')->config('title')]))->setBody(App::view('system/user:mails/reset.php', compact('user', 'url', 'mail')), 'text/html')->send();
         } catch (\Exception $e) {
             throw new Exception(__('Unable to send confirmation link.'));
         }
         $user->save();
         return ['message' => __('Check your email for the confirmation link.')];
     } catch (Exception $e) {
         App::abort(400, $e->getMessage());
     }
 }
開發者ID:nstaeger,項目名稱:pagekit,代碼行數:35,代碼來源:ResetPasswordController.php

示例2: sendMail

 /**
  * @return MailHelper
  */
 public function sendMail()
 {
     if (!($adminMail = $this->submission->form->get('submitEmail'))) {
         return $this;
     }
     $user_email = $this->submission->email ?: false;
     $mailSubject = $this->replaceString($this->submission->form->get('email_subject'));
     $mailBody = $this->replaceString($this->submission->form->get('email_body'));
     $mailBody = App::content()->applyPlugins($mailBody, ['submission' => $this->submission, 'markdown' => $this->submission->form->get('email_body_markdown')]);
     try {
         /** @var Message $mail */
         $mail = App::mailer()->create();
         if ($user_email && $this->submission->form->get('use_replyto', 0)) {
             $mail->setReplyTo($user_email);
         }
         $mail->setTo($adminMail)->setSubject($mailSubject)->setBody(App::view('bixie/formmaker/mails/template.php', compact('mailBody')), 'text/html')->send();
         if ($user_email) {
             $mail = App::mailer()->create();
             $mail->setTo($user_email)->setSubject($mailSubject)->setBody(App::view('bixie/formmaker/mails/template.php', compact('mailBody')), 'text/html')->send();
         }
     } catch (\Exception $e) {
         throw new Exception(__('Unable to send confirmation mail.'));
     }
     return $this;
 }
開發者ID:Bixie,項目名稱:pagekit-formmaker,代碼行數:28,代碼來源:MailHelper.php

示例3: emailAction

 /**
  * Note: If the mailer is accessed prior to this controller action, this will possibly test the wrong mailer
  *
  * @Request({"option": "array"}, csrf=true)
  */
 public function emailAction($option = [])
 {
     try {
         $config = Arr::merge(App::module('system/mail')->config(), $option);
         $response['success'] = (bool) App::mailer()->create(__('Test email!'), __('Testemail'), $config['from_address'])->send();
         $response['message'] = $response['success'] ? __('Mail successfully sent!') : __('Mail delivery failed!');
     } catch (\Exception $e) {
         $response = ['success' => false, 'message' => sprintf(__('Mail delivery failed! (%s)'), $e->getMessage())];
     }
     return $response;
 }
開發者ID:LibraryOfLawrence,項目名稱:pagekit,代碼行數:16,代碼來源:MailController.php

示例4: sendMail

 /**
  * @return string
  */
 public function sendMail()
 {
     if (!($adminMail = $this->submission->form->get('submitEmail'))) {
         return '';
     }
     $userMail = '';
     $mailSubject = $this->replaceString($this->submission->form->get('email_subject'));
     $mailBody = $this->replaceString($this->submission->form->get('email_body'));
     $mailBody = App::content()->applyPlugins($mailBody, ['submission' => $this->submission, 'markdown' => $this->submission->form->get('email_body_markdown')]);
     try {
         $mail = App::mailer()->create();
         $mail->setTo($adminMail)->setSubject($mailSubject)->setBody(App::view('formmaker:views/mails/template.php', compact('mailBody')), 'text/html')->send();
         if ($this->submission->email) {
             $mail = App::mailer()->create();
             $mail->setTo($this->submission->email)->setSubject($mailSubject)->setBody(App::view('formmaker:views/mails/template.php', compact('mailBody')), 'text/html')->send();
         }
     } catch (\Exception $e) {
         throw new Exception(__('Unable to send confirmation mail.'));
     }
     return $userMail;
 }
開發者ID:nagyistoce,項目名稱:pagekit-formmaker,代碼行數:24,代碼來源:MailHelper.php

示例5: sendApproveMail

 protected function sendApproveMail($user)
 {
     try {
         $mail = App::mailer()->create();
         $mail->setTo(App::module('mail')->config('from_address'))->setSubject(__('Approve an account at %site%.', ['%site%' => App::module('system/site')->config('title')]))->setBody(App::view('system/user:mails/approve.php', compact('user', 'mail')), 'text/html')->send();
     } catch (\Exception $e) {
     }
 }
開發者ID:4nxiety,項目名稱:pagekit,代碼行數:8,代碼來源:RegistrationController.php


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