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

61 行
1.7 KiB
PHP

<?php
// 测试邮件发送脚本 - SSL模式
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>测试邮件发送 - SSL模式</h1>";
echo "<pre>";
$toEmail = 'luoriguodu@qq.com';
try {
$mail = new PHPMailer(true);
$mail->isSMTP();
$mail->Host = 'smtp.qiye.163.com';
$mail->SMTPAuth = true;
$mail->Username = 'noreply@parlz.com';
$mail->Password = 'Zzr20130731';
$mail->SMTPSecure = 'ssl';
$mail->Port = 465;
$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 = '测试邮件';
$mail->Body = '<h1>测试邮件</h1><p>这是一封测试邮件</p>';
echo "\n=== 开始发送邮件 ===";
echo "\n收件人: $toEmail\n";
$mail->send();
echo "\n✅ 邮件发送成功!\n";
} catch (Exception $e) {
echo "\n❌ 邮件发送失败!\n";
echo "错误信息: " . $mail->ErrorInfo . "\n";
echo "异常信息: " . $e->getMessage() . "\n";
}
echo "</pre>";
?>