Files
jj2/cron_send_email.php
LL 69ef47412d feat: 添加基金邮件定时发送功能并优化邮件内容格式
- 新增宝塔面板定时任务脚本 cron_send_email.php
- 添加手动发送邮件按钮到管理界面
- 使用PHPMailer替代原始SMTP实现
- 优化邮件内容格式,按涨跌幅排序基金数据
- 增加邮件发送时间窗口判断逻辑
- 更新项目文档说明定时任务配置
2025-12-12 17:10:03 +08:00

33 lines
907 B
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
/**
* 基金邮件定时发送脚本
* 用于宝塔定时任务调用,无需管理员权限
*/
// 设置时区
ini_set('date.timezone', 'Asia/Shanghai');
try {
// 引入FundMonitorAPI
require_once 'api.php';
$api = new FundMonitorAPI();
// 调用发送基金状态邮件方法传入true参数强制发送
$result = $api->sendFundStatusEmail(true);
// 记录执行结果
$logContent = date('Y-m-d H:i:s') . ' - ' . ($result ? '邮件发送成功' : '邮件发送失败') . PHP_EOL;
file_put_contents('cron_email_log.txt', $logContent, FILE_APPEND);
echo $logContent;
exit(0);
} catch (Exception $e) {
// 记录错误信息
$errorContent = date('Y-m-d H:i:s') . ' - 错误: ' . $e->getMessage() . PHP_EOL;
file_put_contents('cron_email_error_log.txt', $errorContent, FILE_APPEND);
echo $errorContent;
exit(1);
}