Auto-detected SMTP TLS mode
X-Lovable-Edit-ID: edt-d0060b51-1f88-4941-8fe2-7dcb17b9dfa1 Co-authored-by: renee-png <262607627+renee-png@users.noreply.github.com>
This commit is contained in:
@@ -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,
|
||||
|
||||
Reference in New Issue
Block a user