Email: accept SMTP_FROM as "Name <address>"

The whole string was used as the address, so the mail server saw
"Quorla support"@domain and rejected the sender.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
metatroncubeswdev 2026-10-25 16:38:42 -04:00
parent 1e97bbd31f
commit e905236f41

View File

@ -27,7 +27,8 @@ function mailer() {
});
return transport;
}
const fromAddress = () => process.env.SMTP_FROM || process.env.SMTP_USER || "";
// SMTP_FROM may be "support@x.com" or "Quorla <support@x.com>"; nodemailer needs the bare address here.
const fromAddress = () => { const f = process.env.SMTP_FROM || process.env.SMTP_USER || ""; return (f.match(/<([^>]+)>/)?.[1] || f).trim(); };
export const appUrl = (p = "") => `${(process.env.PUBLIC_URL || (process.env.APP_DOMAIN ? `https://${process.env.APP_DOMAIN}` : "http://localhost:4310")).replace(/\/+$/, "")}${p}`;
const esc = (s) => String(s ?? "").replace(/[&<>"]/g, (c) => ({ "&": "&amp;", "<": "&lt;", ">": "&gt;", '"': "&quot;" })[c]);