From 4919ca1021110b88b72756ff7a0653884f6c4c56 Mon Sep 17 00:00:00 2001 From: Jeff Emmett Date: Fri, 3 Apr 2026 15:06:57 -0700 Subject: [PATCH] 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 --- modules/rcart/mod.ts | 22 ++++++++++++++-------- 1 file changed, 14 insertions(+), 8 deletions(-) diff --git a/modules/rcart/mod.ts b/modules/rcart/mod.ts index 6467fa5..e67a3d7 100644 --- a/modules/rcart/mod.ts +++ b/modules/rcart/mod.ts @@ -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;