<ruby id="bdb3f"></ruby>

    <p id="bdb3f"><cite id="bdb3f"></cite></p>

      <p id="bdb3f"><cite id="bdb3f"><th id="bdb3f"></th></cite></p><p id="bdb3f"></p>
        <p id="bdb3f"><cite id="bdb3f"></cite></p>

          <pre id="bdb3f"></pre>
          <pre id="bdb3f"><del id="bdb3f"><thead id="bdb3f"></thead></del></pre>

          <ruby id="bdb3f"><mark id="bdb3f"></mark></ruby><ruby id="bdb3f"></ruby>
          <pre id="bdb3f"><pre id="bdb3f"><mark id="bdb3f"></mark></pre></pre><output id="bdb3f"></output><p id="bdb3f"></p><p id="bdb3f"></p>

          <pre id="bdb3f"><del id="bdb3f"><progress id="bdb3f"></progress></del></pre>

                <ruby id="bdb3f"></ruby>

                ??碼云GVP開源項目 12k star Uniapp+ElementUI 功能強大 支持多語言、二開方便! 廣告
                > 安裝 : composer require phpmailer/phpmailer ***** ` ~~~ /** * 設備或配置系統參數 * @param string $name 參數名稱 * @return string|boolean * @throws \think\Exception * @throws \think\exception\PDOException */ function GetSysConfig($name) { $key = md5(config('database.hostname').'#'.config('database.database').$name); if (Cache::has($key)) { $data = Cache::get($key); } else { $data = Db::name('setting')->where("key", "=", "{$name}")->value("value"); Cache::set($key, $data, 180); } return $data; } ~~~ ` ` ~~~ /** * @param $subject * @param $body * @param $to * @param null $attachment * @return array * @throws \PHPMailer\PHPMailer\Exception * @throws \think\Exception * @throws \think\exception\PDOException * @author: LuckyHhy <jackhhy520@qq.com> * @date: 2020/3/17 * @name: sendMaile * @describe: 郵件發送 */ function sendMaile($subject, $body, $to, &$attachment = null) { $maile = Email::instance(); $maile->subject($subject); $maile->body($body); $maile->to($to); if (isset($attachment) && !empty($attachment)) { if (is_array($attachment)) { foreach ($attachment as $v) { $maile->attachment($v); } } else { $maile->attachment($attachment); } } $result = $maile->send(); if ($result) { $arr = ['code' => 1, 'msg' => '發送成功']; } else { $arr = ['code' => 0, 'msg' => $maile->getError()]; } return $arr; } } ~~~ ` ` ~~~ <?php // +---------------------------------------------------------------------- // | Created by PHPstorm: JRKAdmin框架 [ JRKAdmin ] // +---------------------------------------------------------------------- // | Copyright (c) 2019~2022 [LuckyHHY] All rights reserved. // +---------------------------------------------------------------------- // | SiteUrl: http://www.luckyhhy.cn // +---------------------------------------------------------------------- // | Author: LuckyHhy <jackhhy520@qq.com> // +---------------------------------------------------------------------- // | Date: 2020/1/9-9:19 // +---------------------------------------------------------------------- // | Description: // +---------------------------------------------------------------------- namespace Jrk; use PHPMailer\PHPMailer\PHPMailer; use PHPMailer\PHPMailer\Exception; // Load Composer's autoloader require VENDOR_PATH.'autoload.php'; class Email { /** * 單例對象 */ protected static $instance; /** * phpmailer對象 */ protected $mail = []; /** * 錯誤內容 */ protected $_error = ''; /** * 默認配置 */ public $options = [ 'charset' => 'utf-8', //編碼格式 'debug' => 0, //調式模式 ]; /** * @param array $options * @return static * @throws \think\Exception * @throws \think\exception\PDOException * @author: LuckyHhy <jackhhy520@qq.com> * @date: 2020/3/14 0014 * @name: instance * @describe: */ public static function instance($options = []) { if (is_null(self::$instance)) { self::$instance = new static($options); } return self::$instance; } /** * Email constructor. * @param array $options * @throws \think\Exception * @throws \think\exception\PDOException */ public function __construct($options = []) { $this->options = array_merge($this->options, $options); $securArr = [1 => 'tls', 2 => 'ssl']; $this->mail = new PHPMailer(true); $this->mail->CharSet = $this->options['charset']; $this->mail->SMTPDebug = $this->options['debug']; $this->mail->isSMTP(); $this->mail->SMTPAuth = true; $this->mail->Host = GetSysConfig('mail_smtp_host'); $this->mail->Username = GetSysConfig('mail_smtp_user'); $this->mail->Password = GetSysConfig('mail_smtp_pass'); $this->mail->SMTPSecure = isset($securArr[GetSysConfig('mail_verify_type')]) ? $securArr[GetSysConfig('mail_verify_type')] : ''; $this->mail->Port = GetSysConfig('mail_smtp_port'); //設置發件人 $this->from(GetSysConfig('mail_smtp_user'), GetSysConfig('mail_from_name')); } /** * @param $subject * @return $this * @author: LuckyHhy <jackhhy520@qq.com> * @date: 2020/1/9 * @name: subject * @describe:設置郵件主題 */ public function subject($subject) { $this->options['subject'] = $subject; return $this; } /** * @param $file * @return $this * @author: LuckyHhy <jackhhy520@qq.com> * @date: 2020/1/9 * @name: addAttachment * @describe:添加附件 */ public function attachment($file){ $this->options['attachment'] = $file; return $this; } /** * @param $email * @param string $name * @return $this * @author: LuckyHhy <jackhhy520@qq.com> * @date: 2020/1/9 * @name: from * @describe:設置發件人 */ public function from($email, $name = '') { $this->options['from'] = $email; $this->options['from_name'] = $name; return $this; } /** * @param $email * @param string $name * @return $this * @author: LuckyHhy <jackhhy520@qq.com> * @date: 2020/1/9 * @name: to * @describe:設置收件人 */ public function to($email, $name = '') { $this->options['to'] = $email; $this->options['to_name'] = $name; return $this; } /** * @param $body * @param bool $ishtml * @return $this * @author: LuckyHhy <jackhhy520@qq.com> * @date: 2020/1/9 * @name: message * @describe:設置郵件正文 */ public function body($body, $ishtml = true) { $this->options['body'] = $body; $this->options['ishtml'] = $ishtml; return $this; } /** * @return string * @author: LuckyHhy <jackhhy520@qq.com> * @date: 2020/1/9 * @name: getError * @describe:獲取最后產生的錯誤 */ public function getError() { return $this->_error; } /** * @param $error * @author: LuckyHhy <jackhhy520@qq.com> * @date: 2020/1/9 * @name: setError * @describe:設置錯誤 */ protected function setError($error) { $this->_error = $error; } /** * @return bool * @throws Exception * @throws \think\Exception * @throws \think\exception\PDOException * @author: LuckyHhy <jackhhy520@qq.com> * @date: 2020/3/14 0014 * @name: send * @describe: 發送郵件 */ public function send() { $result = false; switch (GetSysConfig('mail_type')) { case 1: //使用phpmailer發送 $this->mail->setFrom($this->options['from'], $this->options['from_name']); $this->mail->addAddress($this->options['to'], $this->options['to_name']); if (isset($this->options['attachment'])){ $this->mail->addAttachment($this->options['attachment']); } $this->mail->Subject = $this->options['subject']; if ($this->options['ishtml']) { $this->mail->msgHTML($this->options['body']); } else { $this->mail->Body = $this->options['body']; } try { $result = $this->mail->send(); } catch (\Exception $e) { $this->setError($e->getMessage()); } $this->setError($result ? '' : $this->mail->ErrorInfo); break; case 2: //使用mail方法發送郵件 $headers = 'MIME-Version: 1.0' . "\r\n"; $headers .= "Content-type: text/html; charset=" . $this->options['charset'] . "\r\n"; $headers .= "To: {$this->options['to_name']} <{$this->options['to']}>\r\n"; //收件人 $headers .= "From: {$this->options['from_name']} <{$this->options['from']}>\r\n"; //發件人 $result = mail($this->options['to'], $this->options['subject'], $this->options['body'], $headers); $this->setError($result ? '' : error_get_last()['message']); break; default: //郵件功能已關閉 $this->setError('Mail already closed'); break; } return $result; } } ~~~ `
                  <ruby id="bdb3f"></ruby>

                  <p id="bdb3f"><cite id="bdb3f"></cite></p>

                    <p id="bdb3f"><cite id="bdb3f"><th id="bdb3f"></th></cite></p><p id="bdb3f"></p>
                      <p id="bdb3f"><cite id="bdb3f"></cite></p>

                        <pre id="bdb3f"></pre>
                        <pre id="bdb3f"><del id="bdb3f"><thead id="bdb3f"></thead></del></pre>

                        <ruby id="bdb3f"><mark id="bdb3f"></mark></ruby><ruby id="bdb3f"></ruby>
                        <pre id="bdb3f"><pre id="bdb3f"><mark id="bdb3f"></mark></pre></pre><output id="bdb3f"></output><p id="bdb3f"></p><p id="bdb3f"></p>

                        <pre id="bdb3f"><del id="bdb3f"><progress id="bdb3f"></progress></del></pre>

                              <ruby id="bdb3f"></ruby>

                              哎呀哎呀视频在线观看