文件
Parlz/send_test_email_final.php
T
2026-06-04 22:42:27 +08:00

63 行
2.0 KiB
PHP

<?php
// 测试邮件发送脚本 - 使用授权码
require_once 'vendor/phpmailer/phpmailer/src/Exception.php';
require_once 'vendor/phpmailer/phpmailer/src/SMTP.php';
require_once 'vendor/phpmailer/phpmailer/src/PHPMailer.php';
use PHPMailer\PHPMailer\PHPMailer;
use PHPMailer\PHPMailer\Exception;
echo "<h1>测试邮件发送 - 使用授权码</h1>";
echo "<pre>";
$toEmail = 'luoriguodu@qq.com';
$verificationCode = 'TEST' . time();
try {
$mail = new PHPMailer(true);
$mail->isSMTP();
$mail->Host = 'smtp.qiye.163.com';
$mail->SMTPAuth = true;
$mail->Username = 'noreply@parlz.com';
$mail->Password = '#5q8HhphvBCWr4n8'; // 用户提供的授权码
$mail->SMTPSecure = 'tls';
$mail->Port = 587;
$mail->Timeout = 30;
$mail->SMTPTimeout = 30;
$mail->SMTPOptions = array(
'ssl' => array(
'verify_peer' => false,
'verify_peer_name' => false,
'allow_self_signed' => true
)
);
$mail->setLanguage('zh_CN', __DIR__ . '/vendor/phpmailer/phpmailer/language/');
$mail->SMTPDebug = 2;
$mail->Debugoutput = function($str, $level) {
echo "DEBUG [$level]: $str\n";
};
$mail->setFrom('noreply@parlz.com', 'Parlz');
$mail->addAddress($toEmail, '测试用户');
$mail->isHTML(true);
$mail->CharSet = 'UTF-8';
$mail->Subject = '邮箱验证 - Parlz';
$mail->Body = "<h1>邮箱验证</h1><p>您的验证码:<strong>$verificationCode</strong></p><p>点击链接验证:https://www.parlz.com/index.php?action=verify_email&code=$verificationCode</p>";
echo "\n=== 开始发送邮件 ===";
echo "\n收件人: $toEmail\n";
$mail->send();
echo "\n✅ 邮件发送成功!\n";
echo "请检查邮箱 $toEmail 查看验证邮件。\n";
} catch (Exception $e) {
echo "\n❌ 邮件发送失败!\n";
echo "错误信息: " . $mail->ErrorInfo . "\n";
echo "异常信息: " . $e->getMessage() . "\n";
}
echo "</pre>";
?>