From a3aa53fe6e548b18c57d41f62d034481e8eab827 Mon Sep 17 00:00:00 2001 From: Rohit Saini <71682713+RohitSaini15@users.noreply.github.com> Date: Thu, 10 Aug 2023 22:49:21 +0530 Subject: [PATCH] fix: #10614 - made nodemailer compatible with mailhog smtp server. (#10615) * mailhog server auth problem solved * put condition on transport auth * fixe type-check error --- packages/lib/serverConfig.ts | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) 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,