fix(rcart): use port 25 internal relay for payment emails
SMTP auth credentials were stale, causing all payment confirmation emails to silently fail. Since rspace is on the mailcow Docker network, use unauthenticated relay on port 25 instead of port 587 with auth. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
parent
55067729b1
commit
4919ca1021
|
|
@ -49,15 +49,21 @@ let _smtpTransport: Transporter | null = null;
|
|||
|
||||
function getSmtpTransport(): Transporter | null {
|
||||
if (_smtpTransport) return _smtpTransport;
|
||||
if (!process.env.SMTP_PASS) return null;
|
||||
const host = process.env.SMTP_HOST || "mail.rmail.online";
|
||||
const isInternal = host.includes('mailcow') || host.includes('postfix');
|
||||
if (!process.env.SMTP_PASS && !isInternal) return null;
|
||||
// Internal mailcow network: relay on port 25 without auth
|
||||
// External: use port 587 with STARTTLS + auth
|
||||
_smtpTransport = createTransport({
|
||||
host: process.env.SMTP_HOST || "mail.rmail.online",
|
||||
port: Number(process.env.SMTP_PORT) || 587,
|
||||
secure: Number(process.env.SMTP_PORT) === 465,
|
||||
auth: {
|
||||
user: process.env.SMTP_USER || "noreply@rmail.online",
|
||||
pass: process.env.SMTP_PASS,
|
||||
},
|
||||
host,
|
||||
port: isInternal ? 25 : (Number(process.env.SMTP_PORT) || 587),
|
||||
secure: !isInternal && Number(process.env.SMTP_PORT) === 465,
|
||||
...(isInternal ? {} : {
|
||||
auth: {
|
||||
user: process.env.SMTP_USER || "noreply@rmail.online",
|
||||
pass: process.env.SMTP_PASS!,
|
||||
},
|
||||
}),
|
||||
tls: { rejectUnauthorized: false },
|
||||
});
|
||||
return _smtpTransport;
|
||||
|
|
|
|||
Loading…
Reference in New Issue