Files

35 lines
1.4 KiB
PHP
Raw Permalink Normal View History

2022-01-07 11:15:42 +08:00
<?php
/**
* SMTP 配置
*
* ⚠️ 这个文件过去自己发过两类邮件(回复通知、审核通过通知),
* 与 wpDiscuz 插件的通知**完全重复**,是「一条评论收到多封邮件」的
* 直接原因之一。现已全部移除。
*
* 发信通道的接管逻辑统一在 inc/theme-mail.php,
* 邮件模板在 inc/theme-mail-template.php。
* 本文件只保留 SMTP 连通性相关的部分。
*
* @author Yongquan Yang <yangyq.net>
2022-01-07 11:15:42 +08:00
* @license MIT License
* @version 2020.02.15
*/
if (!defined('ABSPATH')) {
exit;
2022-01-07 11:15:42 +08:00
}
// 兼容旧版本:早期这里是 mail_smtp(),挂 phpmailer_init(优先级默认 10)。
// 现在由 inc/theme-mail.php 的 yang_mail_configure_phpmailer(优先级 9999)接管,
// 因为它还要处理「配置不完整不接管」「清掉别的插件残留配置」等情形。
// 这里刻意不再注册任何 phpmailer_init,避免两套配置互相覆盖。
2022-01-07 11:15:42 +08:00
// Debug:只在 WP_DEBUG 且显式开启时记录
if (defined('WP_DEBUG') && WP_DEBUG && kratos_option('m_debug_log', false)) {
add_action('wp_mail_failed', function ($error) {
$data = $error->get_error_data();
error_log('[yang_mail] 发送失败: ' . $error->get_error_message()
. ' | to=' . (isset($data['to']) && is_array($data['to']) ? implode(',', $data['to']) : '')
. ' | subject=' . (isset($data['subject']) ? $data['subject'] : ''));
}, 10, 1);
}