<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>

                企業??AI智能體構建引擎,智能編排和調試,一鍵部署,支持知識庫和私有化部署方案 廣告
                [TOC] ## phpMailer 的特點 phpMailer 是一個非常強大的 ph p發送郵件類,可以設定發送郵件地址、回復地址、郵件主題、html網頁,上傳附件,并且使用起來非常方便。 **phpMailer 的特點:** * 1、在郵件中包含多個 TO、CC、BCC 和 REPLY-TO。 * 2、平臺應用廣泛,支持的 SMTP 服務器包括 Sendmail、qmail、Postfix、Gmail、Imail、Exchange 等等。 * 3、支持嵌入圖像,附件,HTML 郵件。 * 4、可靠的強大的調試功能。 * 5、支持 SMTP 認證。 * 6、自定義郵件頭。 * 7、支持 8bit、base64、binary 和 quoted-printable 編碼。 phpmailer 安裝或者下載方式: 1、從 github 上下載:[https://github.com/PHPMailer/PHPMailer/](https://github.com/PHPMailer/PHPMailer/) 2、使用 composer 安裝: ~~~ composer require phpmailer/phpmailer ~~~ 發送之前需要擁有自己的郵件服務器,測試的時候其實用自己申請的免費郵箱最方便了,不需要自己再搭建服務器了,可能要配置郵箱的SMTP服務,大部分公共郵箱(163、qq等)為了安全默認是關閉的。 網易郵箱配置如下圖: ![](https://www.runoob.com/wp-content/uploads/2018/09/201102010936447869c.png) QQ 郵箱相關配置如下圖: | 郵箱 | POP3服務器(端口995) | SMTP服務器(端口465或587) | | --- | --- | --- | | qq.com | pop.qq.com | smtp.qq.com | ## 163郵箱測試,先開啟SMTP ![](https://img.kancloud.cn/9b/92/9b929a2d56bb297fe1b814049b0e494f_1089x735.png) 當然除了網易和 QQ 郵箱其他郵箱也是可以的,下面給出 php 代碼示例: ## 實例 ~~~ use PHPMailer\PHPMailer\PHPMailer $mail = new PHPMailer(true); // Passing `true` enables exceptions try { //服務器配置 $mail->CharSet ="UTF-8"; //設定郵件編碼 $mail->SMTPDebug = 0; // 調試模式輸出 $mail->isSMTP(); // 使用SMTP $mail->Host = 'smtp.163.com'; // SMTP服務器 $mail->SMTPAuth = true; // 允許 SMTP 認證 $mail->Username = 'xxxx@163.com'; // SMTP 用戶名 即郵箱的用戶名 // $mail->Password = 'ZGxxxxxxxx'; // SMTP 密碼 部分郵箱是授權碼(例如163郵箱) $mail->SMTPSecure = 'ssl'; // 允許 TLS 或者ssl協議 $mail->Port = 465; // 服務器端口 25 或者465 具體要看郵箱服務器支持 $mail->setFrom('xxxx@163.com', 'Mailer'); //發件人 $mail->addAddress('xxxx@163.com', 'Joe'); // 收件人 //$mail->addAddress('ellen@example.com'); // 可添加多個收件人 $mail->addReplyTo('xxxx@163.com', 'info'); //回復的時候回復給哪個郵箱 建議和發件人一致 //$mail->addCC('cc@example.com'); //抄送 //$mail->addBCC('bcc@example.com'); //密送 //發送附件,文件目錄我是laravel,存的文件目錄再public下面,所以一下路徑是對的 // $mail->addAttachment('./upload/files/xy.zip'); // 添加附件,用這個顯示名稱默認文件名稱 // $mail->addAttachment('./upload/files/thumb-1.jpg', 'new.jpg'); // 發送附件并且重命名,用這個顯示名稱可以自定義 //如果需要在郵件內容里面貼圖片,需要填寫下面語句,然后再html代碼里面使用<img src="cid:weixin_img" >來接收 //切記,如果附件和圖片同時存在,需要 先添加附件再添加圖片,不然圖片不顯示(PS:發現也沒用了,2個不能同時存在, 目前沒有找到解決辦法,如果你能解決了給我留個言唄,謝謝) $this->mail->addEmbeddedImage('./weixin.jpg','weixin_img'); // 添加圖片 //Content $mail->isHTML(true); // 是否以HTML文檔格式發送 發送后客戶端可直接顯示對應HTML內容 $mail->Subject = '這里是郵件標題' . time(); $mail->Body = '<h1>這里是郵件內容</h1>' . date('Y-m-d H:i:s'); $mail->AltBody = '如果郵件客戶端不支持HTML則顯示此內容'; $mail->send(); return ['code' => 0, 'msg' => '郵件發送成功', 'response' => []]; } catch (\Exception $e) { return ['code' => 1, 'msg' => $mail->ErrorInfo, 'response' => []]; } ~~~ 附件目錄結構 ![](https://img.kancloud.cn/2d/4f/2d4ff8c366e6cf53acee9cafd4ee0471_655x195.png) ## 發送完帶附件的郵件界面如下 ![](https://img.kancloud.cn/7d/ff/7dff466c57783d0095f76d03eacc15ac_687x406.png) ~~~ 文章來源:https://www.liminghulian.com/article/98 ~~~
                  <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>

                              哎呀哎呀视频在线观看