<?php
ini_set('date.timezone','Asia/Shanghai');
use PHPMailer\PHPMailer\PHPMailer;
use PHPMailer\PHPMailer\Exception;
require 'PHPMailer/src/Exception.php';
require 'PHPMailer/src/PHPMailer.php';
require 'PHPMailer/src/SMTP.php';
$mail = new PHPMailer();
$mail->SMTPDebug = 1;
$mail->isSMTP();
$mail->SMTPAuth=true;
$mail->Host = 'smtp.qq.com';
$mail->SMTPSecure = 'ssl';
$mail->Port = 465;
$mail->Helo = 'Hello smtp.qq.com Server';
$mail->Hostname = 'haiyun.me';
$mail->CharSet = 'UTF-8';
$mail->Username ='admin@haiyun.me';
$mail->Password = 'password';
$mail->FromName = 'fromuser';
$mail->From = 'admin@haiyun.me';
$mail->isHTML(true);
$mail->addAddress('touser@haiyun.me','touser');
$mail->Subject = "这是标题";
$mail->Body = "这是内容";
$status = $mail->send();
if($status) {
echo '发送邮件成功'."\n";
}else{
echo '发送邮件失败,错误信息:'.$mail->ErrorInfo."\n";
}
标签:none