diff --git a/packages/lib/serverConfig.ts b/packages/lib/serverConfig.ts index 23bf7343dd..3e6d10993e 100644 --- a/packages/lib/serverConfig.ts +++ b/packages/lib/serverConfig.ts @@ -10,13 +10,18 @@ function detectTransport(): SendmailTransport.Options | SMTPConnection.Options | if (process.env.EMAIL_SERVER_HOST) { const port = parseInt(process.env.EMAIL_SERVER_PORT || ""); + const auth = + process.env.EMAIL_SERVER_USER && process.env.EMAIL_SERVER_PASSWORD + ? { + user: process.env.EMAIL_SERVER_USER, + pass: process.env.EMAIL_SERVER_PASSWORD, + } + : undefined; + const transport = { host: process.env.EMAIL_SERVER_HOST, port, - auth: { - user: process.env.EMAIL_SERVER_USER, - pass: process.env.EMAIL_SERVER_PASSWORD, - }, + auth, secure: port === 465, tls: { rejectUnauthorized: !isENVDev,