修复:邮件通知两处静默失效(测试暴露)

症状:notify_log 全表为空 → 用户报「完全没发邮件」,后台查不到任何线索。

1. 前 4 个前置判断(开关/收件人/自己回自己/冷却)直接 return 不写日志,
   等于「为什么没发」完全无痕。改为任何退出路径都写 notify_log,
   并带上可读原因。

2. new 事件(新反馈通知管理员)收件人只取 admin_email,该值为空时整条
   通知静默失效 —— 管理员永远收不到新反馈信,界面也无任何提示。
   改为回落 smtp.user / smtp.from;后台勾了「通知管理员」却没填邮箱时
   当场显示警告。

验证:走 fb_notify_event 全事件测试,6 个事件全部写日志、new 能送达。
This commit is contained in:
2026-11-03 07:31:35 +08:00
parent 8a850ca0e5
commit e43f2ce67a
2 changed files with 41 additions and 5 deletions
+15 -2
View File
@@ -1326,8 +1326,21 @@ fb_layout_head('管理后台', ['robots' => 'noindex,nofollow']);
<h3 style="margin:20px 0 8px;font-size:15px">通知规则</h3>
<label class="check"><input type="checkbox" name="notify_enabled" value="1"<?php echo fb_cfg('notify.enabled', true) ? ' checked' : ''; ?>> 有人回复时通知提交人</label>
<label class="check"><input type="checkbox" name="notify_on_every_reply" value="1"<?php echo fb_cfg('notify.on_every_reply', false) ? ' checked' : ''; ?>> 每次回复都通知(默认只在官方回复时通知,避免刷屏)</label>
<label class="check"><input type="checkbox" name="notify_admin_new_thread" value="1"<?php echo fb_cfg('notify.admin_new_thread', false) ? ' checked' : ''; ?>> 有新反馈时通知管理员
<span class="hint" style="display:block;margin-left:24px">发到「站点信息」里填的官方邮箱。</span></label>
<?php
// 勾了「有新反馈时通知管理员」却没填官方邮箱 —— 这条通知会发不出去。
// 之前这个组合完全是静默失效的,用户在后台看不出任何异常。
$adminMailNow = trim((string)fb_cfg('admin_email', ''));
$smtpUserNow = trim((string)fb_cfg('smtp.user', ''));
$newNotifyOn = (bool)fb_cfg('notify.admin_new_thread', false);
$mailMissing = ($adminMailNow === '' && $smtpUserNow === '');
?>
<label class="check"><input type="checkbox" name="notify_admin_new_thread" value="1"<?php echo $newNotifyOn ? ' checked' : ''; ?>> 有新反馈时通知管理员
<span class="hint" style="display:block;margin-left:24px">发到「站点信息」里填的官方邮箱;没填官方邮箱时退而发到 SMTP 发件地址。</span>
<?php if ($newNotifyOn && $mailMissing): ?>
<span class="hint" style="display:block;margin-left:24px;color:#b4553c;font-weight:600">⚠️ 官方邮箱和 SMTP 发件地址都是空的,这条通知目前发不出去。请在上方「官方邮箱」处填写。</span>
<?php elseif ($newNotifyOn && $adminMailNow === ''): ?>
<span class="hint" style="display:block;margin-left:24px;color:#8a6a15">当前会发到 SMTP 发件地址 <?php echo e($smtpUserNow); ?>。若想收到别的信箱,请在「站点信息」填写官方邮箱。</span>
<?php endif; ?></label>
<label class="field" style="max-width:280px"><span>同一帖同一收件人的最短发信间隔(秒)</span>
<?php /* 出厂默认是 300(见 config.example.php 的 notify.cooldown_seconds) */ ?>
<input type="number" name="notify_cooldown_seconds" min="0" max="86400" placeholder="300"