fix(email): set sender before PHPMailer init

This commit is contained in:
2026-09-04 13:56:11 +08:00
parent 0d7d4fea61
commit 05f40d7728
2 changed files with 24 additions and 8 deletions
@@ -47,7 +47,14 @@ test('email templates and SMTP use one aksrt_settings schema', () => {
})
test('SMTP authentication and failures use the canonical mail service', () => {
assert.match(coreHooks, /add_filter\('wp_mail_from',/)
assert.match(coreHooks, /add_filter\('wp_mail_from_name',/)
assert.match(coreHooks, /if \(empty\(\$mail\['enabled'\]\)\) return \$from/)
assert.match(coreHooks, /if \(empty\(\$mail\['enabled'\]\)\) return \$from_name/)
assert.match(coreHooks, /\$mail\['from_address'\]/)
assert.match(coreHooks, /\$mail\['from_name'\]/)
assert.match(coreHooks, /\$phpmailer->SMTPAuth\s*=\s*!empty\(\$mail\['auth'\]\)\s*&&\s*!empty\(\$mail\['username'\]\)/)
assert.doesNotMatch(coreHooks, /\$phpmailer->setFrom\(/)
assert.match(mail, /add_action\('wp_mail_failed',\s*\$capture_failure\)/)
assert.match(mail, /remove_action\('wp_mail_failed',\s*\$capture_failure\)/)
assert.match(mail, /error_log\('\[AKSRT\] SMTP 测试失败:'/)