<?php

namespace app\home\logic;

use phpmailer\phpmailer\phpmailer;
use phpmailer\phpmailer\exception;

class qqmail{
       public static function qq($addr,$code){
           $mail = new phpmailer(true);
           try{
               //邮件调试模式
               $mail->smtpdebug = 1;
               //设置邮件使用smtp
               $mail->issmtp();
               // 设置邮件程序以使用smtp
               $mail->host = 'smtp.qq.com';
               $mail->issmtp();
               // 设置邮件内容的编码
               $mail->charset='utf-8';
               // 启用smtp验证
               $mail->smtpauth = true;
               // smtp username
               $mail->username = '*****@qq.com';
               // smtp password
               $mail->password = '*******';
               // 连接的tcp端口
//            $mail->port = 465;
               //设置发件人昵称
               $mail->fromname='*****';
               //设置发件人
               $mail->setfrom('****@qq.com');
               //  添加收件人1
               $mail->addaddress($addr);
               // 将电子邮件格式设置为html
               $mail->ishtml(true);
               $mail->subject = '标题';
               $mail->body    = '文本';
//            $mail->altbody = '这是非html邮件客户端的纯文本';
               $mail->send();
               echo 'message has been sent';

           }catch (exception $e){
               echo 'mailer error: ' . $mail->errorinfo;
           }
       }
}