Allow self signed cert for stalwart

This commit is contained in:
Greg Kilmer
2026-07-07 22:10:17 -04:00
parent e7c5e9d66e
commit 59bcf495bf
3 changed files with 31 additions and 0 deletions
+9
View File
@@ -167,11 +167,20 @@ async function deliver(msg: Message): Promise<boolean> {
const nodemailer = (await import('nodemailer')).default;
const port = Number(smtpPort() ?? 587);
const user = smtpUser();
// Accept self-signed certificates when explicitly opted in. Intended for
// internal homelab hops where the SMTP relay (e.g. Stalwart on the same
// Docker network) presents a self-signed cert and the connection never
// traverses an untrusted network. Defaults to false so production-grade
// TLS verification is the default; the override is a deliberate choice.
const allowSelfSigned = env('SMTP_ALLOW_SELFSIGNED') === 'true';
const transport = nodemailer.createTransport({
host,
port,
secure: port === 465,
auth: user ? { user, pass: smtpPass() } : undefined,
...(allowSelfSigned
? { tls: { rejectUnauthorized: false } }
: {}),
});
const hostname = (() => {
try {