feat: 添加基金邮件定时发送功能并优化邮件内容格式
- 新增宝塔面板定时任务脚本 cron_send_email.php - 添加手动发送邮件按钮到管理界面 - 使用PHPMailer替代原始SMTP实现 - 优化邮件内容格式,按涨跌幅排序基金数据 - 增加邮件发送时间窗口判断逻辑 - 更新项目文档说明定时任务配置
This commit is contained in:
44
send_fund_email.php
Normal file
44
send_fund_email.php
Normal file
@@ -0,0 +1,44 @@
|
||||
<?php
|
||||
/**
|
||||
* 单独处理发送基金状态邮件的请求
|
||||
*/
|
||||
|
||||
// 设置响应头
|
||||
header('Content-Type: application/json; charset=utf-8');
|
||||
header('Access-Control-Allow-Origin: *');
|
||||
header('Access-Control-Allow-Methods: GET, POST, OPTIONS');
|
||||
header('Access-Control-Allow-Headers: Content-Type, charset');
|
||||
|
||||
// 处理OPTIONS请求
|
||||
if ($_SERVER['REQUEST_METHOD'] === 'OPTIONS') {
|
||||
exit(0);
|
||||
}
|
||||
|
||||
// 验证管理员权限
|
||||
session_start();
|
||||
// 调试模式:允许通过debug参数绕过权限验证
|
||||
$isDebugMode = (isset($_GET['debug']) && $_GET['debug'] === 'true') || (isset($_POST['debug']) && $_POST['debug'] === 'true');
|
||||
if (!$isDebugMode && (!isset($_SESSION['admin_logged_in']) || $_SESSION['admin_logged_in'] !== true)) {
|
||||
http_response_code(403);
|
||||
echo json_encode(['success' => false, 'error' => '权限不足']);
|
||||
exit;
|
||||
}
|
||||
|
||||
// 引入FundMonitorAPI
|
||||
require_once 'api.php';
|
||||
$api = new FundMonitorAPI();
|
||||
|
||||
try {
|
||||
// 调用发送基金状态邮件方法,传入true参数强制发送
|
||||
$result = $api->sendFundStatusEmail(true);
|
||||
if ($result) {
|
||||
echo json_encode(['success' => true, 'message' => '邮件发送成功']);
|
||||
} else {
|
||||
echo json_encode(['success' => false, 'error' => '邮件发送失败,请查看日志']);
|
||||
}
|
||||
} catch (Exception $e) {
|
||||
http_response_code(500);
|
||||
echo json_encode(['success' => false, 'error' => $e->getMessage()]);
|
||||
}
|
||||
|
||||
exit(0);
|
||||
Reference in New Issue
Block a user