当前位置: 首页>>代码示例>>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;未经允许,请勿转载。