From ca12fea590a7ba89beb93c3c032400e61c7767c1 Mon Sep 17 00:00:00 2001 From: "gpt-engineer-app[bot]" <159125892+gpt-engineer-app[bot]@users.noreply.github.com> Date: Fri, 17 Apr 2026 23:05:58 +0000 Subject: [PATCH] Changes Co-authored-by: renee-png <262607627+renee-png@users.noreply.github.com> --- supabase/functions/send-smtp-email/index.ts | 16 +++++++++++++++- 1 file changed, 15 insertions(+), 1 deletion(-) diff --git a/supabase/functions/send-smtp-email/index.ts b/supabase/functions/send-smtp-email/index.ts index 24c5f0a..802b466 100644 --- a/supabase/functions/send-smtp-email/index.ts +++ b/supabase/functions/send-smtp-email/index.ts @@ -62,11 +62,25 @@ Deno.serve(async (req) => { return json({ error: "to and subject are required" }, 400); } + // Auto-correct common TLS misconfigurations: + // - Port 465 always uses implicit TLS (tls: true) + // - Port 587 / 25 use STARTTLS (tls: false; denomailer upgrades automatically) + let useTls = !!settings.secure; + if (settings.port === 465) useTls = true; + else if (settings.port === 587 || settings.port === 25) useTls = false; + + console.log("SMTP connecting", { + host: settings.host, + port: settings.port, + tls: useTls, + hasAuth: !!settings.username, + }); + const client = new SMTPClient({ connection: { hostname: settings.host, port: settings.port, - tls: !!settings.secure, + tls: useTls, auth: settings.username ? { username: settings.username, password } : undefined,