From b88c707ff3ec5631659e10c7c765ac8e97f0a3d4 Mon Sep 17 00:00:00 2001 From: Andrew Isherwood Date: Thu, 3 Dec 2020 13:53:38 +0000 Subject: [PATCH] Do not use an object for SMTP options Objects do not appear to work when supplying ecosystem config options, so move the two SMTP options into their own lines in the config --- ecosystem.config.js.template | 14 ++++---------- lib.js | 7 +++++-- 2 files changed, 9 insertions(+), 12 deletions(-) diff --git a/ecosystem.config.js.template b/ecosystem.config.js.template index 200100f..7c9f152 100644 --- a/ecosystem.config.js.template +++ b/ecosystem.config.js.template @@ -17,11 +17,8 @@ module.exports = { BASE_URL: '', FROM: '', REPLY_TO: '', - // See https://nodemailer.com/smtp/ for all options - SMTP_OPTIONS: { - port: '', - host: '' - } + SMTP_HOST: '', + SMTP_PORT: '' }, env_production: { NODE_ENV: 'production', @@ -31,11 +28,8 @@ module.exports = { BASE_URL: '' FROM: '', REPLY_TO: '', - // See https://nodemailer.com/smtp/ for all options - SMTP_OPTIONS: { - port: '', - host: '' - } + SMTP_HOST: '', + SMTP_PORT: '' } } ] diff --git a/lib.js b/lib.js index bad5f4d..8d6c14e 100644 --- a/lib.js +++ b/lib.js @@ -4,8 +4,11 @@ const nodemailer = require('nodemailer'); const db = require('../ems-db'); const email = new Email(); -let smtpOptions = JSON.parse(process.env.SMTP_OPTIONS); -smtpOptions = {...smtpOptions, send: true}; +const smtpOptions = { + send: true, + host: process.env.SMTP_HOST, + port: process.env.SMTP_PORT +}; const transporter = nodemailer.createTransport(smtpOptions); const sendEmail = async ({to, name, queries, type}) => {