久久久久久久视色,久久电影免费精品,中文亚洲欧美乱码在线观看,在线免费播放AV片

<center id="vfaef"><input id="vfaef"><table id="vfaef"></table></input></center>

    <p id="vfaef"><kbd id="vfaef"></kbd></p>

    
    
    <pre id="vfaef"><u id="vfaef"></u></pre>

      <thead id="vfaef"><input id="vfaef"></input></thead>

    1. 站長(zhǎng)資訊網(wǎng)
      最全最豐富的資訊網(wǎng)站

      詳解TP怎么配合phpmailer實(shí)現(xiàn)發(fā)郵件功能

      下面thinkphp框架教程欄目將給大家講解TP怎么配合phpmailer實(shí)現(xiàn)發(fā)郵件功能,希望對(duì)需要的朋友有所幫助!

      TP配合phpmailer發(fā)郵件功能

      • 在https://packagist.org查找phpmailer

      • 使用composer下載phpmailer下載到項(xiàng)目中

      composer require phpmailer/phpmailer
      • 把phpmailer配置代碼

      //將PHPMailer類導(dǎo)入全局名稱空間 //這些必須在腳本的頂部,而不是在函數(shù)內(nèi)部 use PHPMailerPHPMailerPHPMailer; use PHPMailerPHPMailerException; // Load Composer的自動(dòng)加載器 function send_email($to,$subject='',$content=''){     //實(shí)例化并傳遞`true`會(huì)啟用異常     $mail = new PHPMailer(true);     //服務(wù)器設(shè)置     try {         //Server settings         $mail->SMTPDebug = 2;                       //啟用詳細(xì)調(diào)試輸出 2詳細(xì)  1簡(jiǎn)單  0不顯示         $mail->isSMTP();                                            //使用SMTP         $mail->Host       = 'smtp.qq.com';                    //將SMTP服務(wù)器設(shè)置為通過         $mail->SMTPAuth   = true;                                   //啟用SMTP驗(yàn)證         $mail->Username   = '1758604817@qq.com';                     // SMTP用戶名         $mail->Password   = 'uzbslzhwjbjqejic';                     // 郵箱的授權(quán)碼,不是郵箱密碼         $mail->SMTPSecure = 'ssl';        //啟用TLS加密;`的PHPMailer :: ENCRYPTION_SMTPS`鼓勵(lì)         $mail->Port       = 465;                                     //要連接的TCP端口,對(duì)于上面的`PHPMailer :: ENCRYPTION_SMTPS`使用465         //收件人         $mail->setFrom('1758604817@qq.com', 'pigment');         $mail->addAddress($to);     //添加收件人 //        $mail->addAddress('ellen@example.com');               //名稱是可選的 //        $mail->addReplyTo('info@example.com', 'Information'); //        $mail->addCC('cc@example.com'); //        $mail->addBCC('bcc@example.com');         //附件 //        $mail->addAttachment('/var/tmp/file.tar.gz');         //添加附件 //        $mail->addAttachment('/tmp/image.jpg', 'new.jpg');     //可選名稱         //內(nèi)容         $mail->isHTML(true);                                  //將電子郵件格式設(shè)置為HTML         $mail->Subject = $subject;         $mail->Body    = $content;         return $mail->send();     } catch (Exception $e) {         return $mail->ErrorInfo;     } }

      把該方法添加到application的common文件中,把它封裝成一個(gè)方法,這樣在任何地方都可以調(diào)用

      注意事項(xiàng)

      注意項(xiàng)學(xué)會(huì)在debug中排錯(cuò)

      數(shù)據(jù)庫鏈接問題 表名是否有錯(cuò)

      郵箱授權(quán)碼和郵箱密碼不是一個(gè)東西,這點(diǎn)很重要

      推薦:《最新的10個(gè)thinkphp視頻教程》

      贊(0)
      分享到: 更多 (0)
      網(wǎng)站地圖   滬ICP備18035694號(hào)-2    滬公網(wǎng)安備31011702889846號(hào)