ThinkChat2.0新版上线,更智能更精彩,支持会话、画图、阅读、搜索等,送10W Token,即刻开启你的AI之旅 广告
``` 安装 composer require phpmailer/phpmailer ``` ``` <?php namespace lib; use PHPMailer\PHPMailer\PHPMailer; class Sms{ //发送邮箱验证码 public function send($username,$content) { $mail = new PHPMailer(); $mail->IsSMTP(); // 使用SMTP方式发送 $mail->SMTPSecure = 'ssl'; $mail->CharSet='UTF-8'; $mail->Host = 'smtp.qq.com'; $mail->Port = '465'; // 设置端口 $mail->SMTPAuth = true; // 启用SMTP验证功能 //$mail->Username = '12360577@qq.com'; //$mail->Password = 'a18530946336'; $mail->Username = '2778063859@qq.com'; $mail->Password = 'hqtuebidwnendghd'; $mail->From = '2778063859@qq.com'; $mail->FromName = '可呗应用内测分发平台'; $mail->AddAddress($username, '用户'); $mail->IsHTML(true); $mail->Subject = '尊敬的用户您好'; $mail->Body = $content; //邮件内容 $res = $mail->send(); if($res){// 发送邮件 return true; }else{ return false; } } } ```