Fix SMTP auth: settings tab saved wrong config keys
The Settings → E-mailrapport tab (scheduler.js) saved the SMTP username as `user` and TLS flag as `starttls`, but every backend reader expects `username`/`use_tls` (routes/email.py). Result: username was always empty, server.login() was skipped, and the SMTP server rejected the send — surfacing as a misleading "authentication failed" message even with a valid App Password. The bug was latent because Graph is preferred whenever M365 is connected, so the SMTP path was rarely exercised. - scheduler.js: send/load canonical keys (username, use_tls). The send-report modal (scan.js) already used these. - _load_smtp_config(): normalise legacy user→username / starttls→use_tls so configs saved before the fix work without re-entry. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
This commit is contained in:
1 parent
b661a94f98
commit
526e2b0b78
4 files changed
+49
-4
No files matched your search
@@ -314,11 +314,11 @@ function stLoadSmtp() {
|
||||
const set = function(id, val) { const el=document.getElementById(id); if(el) el.value=val||''; };
|
||||
set('st-smtpHost', d.host);
|
||||
set('st-smtpPort', d.port || 587);
|
||||
set('st-smtpUser', d.user);
|
||||
set('st-smtpUser', d.username);
|
||||
set('st-smtpFrom', d.from_addr);
|
||||
set('st-smtpTo', Array.isArray(d.recipients) ? d.recipients.join(', ') : (d.recipients||''));
|
||||
const tls = document.getElementById('st-smtpTls');
|
||||
if (tls) tls.checked = d.starttls !== false;
|
||||
if (tls) tls.checked = d.use_tls !== false;
|
||||
const pw = document.getElementById('st-smtpPw');
|
||||
if (pw) pw.value = d.has_password ? '\u2022\u2022\u2022\u2022\u2022\u2022\u2022\u2022' : '';
|
||||
const ae = document.getElementById('st-smtpAutoEmail');
|
||||
@@ -333,10 +333,13 @@ async function stSmtpSave() {
|
||||
const body = {
|
||||
host: document.getElementById('st-smtpHost').value.trim(),
|
||||
port: parseInt(document.getElementById('st-smtpPort').value) || 587,
|
||||
user: document.getElementById('st-smtpUser').value.trim(),
|
||||
// Backend (routes/email.py) reads these exact keys — `username`/`use_tls`,
|
||||
// not `user`/`starttls`. Sending the wrong keys leaves username empty so
|
||||
// server.login() is skipped and the SMTP server rejects the send.
|
||||
username: document.getElementById('st-smtpUser').value.trim(),
|
||||
from_addr: document.getElementById('st-smtpFrom').value.trim(),
|
||||
recipients: document.getElementById('st-smtpTo').value.split(/[,;]/).map(function(s){return s.trim();}).filter(Boolean),
|
||||
starttls: document.getElementById('st-smtpTls').checked,
|
||||
use_tls: document.getElementById('st-smtpTls').checked,
|
||||
auto_email_manual: !!(document.getElementById('st-smtpAutoEmail') || {}).checked,
|
||||
};
|
||||
if (pw !== null) body.password = pw;
|
||||
|
||||
Reference in new issue
Block a user