Files
Fuxsto-V3/user/email.php
2025-10-18 14:46:52 +08:00

59 lines
1.3 KiB
PHP
Raw Permalink Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

<?php
include './cgp.php';
// 示例使用
// 引入 PHPMailer 的文件
require 'phpmailer/src/PHPMailer.php';
require 'phpmailer/src/SMTP.php';
require 'phpmailer/src/Exception.php';
use PHPMailer\PHPMailer\PHPMailer;
use PHPMailer\PHPMailer\Exception;
function sendMail($to,$subject,$content) {
$mail = new PHPMailer(true); // 实例化PHPMailer对象
try {
// 邮件服务器配置
$mail->isSMTP(); // 使用SMTP
$mail->Host = '127.0.0.1'; // SMTP服务器地址
$mail->Username = 'cloud@fuxsto.cn'; // SMTP用户名
$mail->Password = ''; // SMTP密码
$mail->SMTPAutoTLS = false; // 禁用自动TLS
$mail->SMTPSecure = ''; // 确保没有加密
$mail->Port = 25; // SMTP端口号
// 发件人和收件人
$mail->setFrom('cloud@fuxsto.cn', 'Fuxsto Mail'); // 发件人
$mail->addAddress($to, $to); // 收件人
// 邮件内容
$mail->isHTML(true); // 设置邮件格式为HTML
$mail->Subject = $subject;
$mail->Body = $content; // HTML格式的邮件内容
$mail->AltBody = $content; // 如果收件人客户端不支持HTML则显示此内容
// 发送邮件
$mail->send();
return 200;
} catch (Exception $e) {
return "邮件发送失败,错误信息: {$mail->ErrorInfo}";
}
}