From d4178513285335baeb7ab1836186bad705ab9639 Mon Sep 17 00:00:00 2001 From: Ankish Kumar Date: Thu, 19 Dec 2024 18:04:29 +0530 Subject: [PATCH] Fix Dynamic smtp config require server restart to reflect changes --- .../src/sender/nodemailer-email-sender.ts | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-) diff --git a/packages/email-plugin/src/sender/nodemailer-email-sender.ts b/packages/email-plugin/src/sender/nodemailer-email-sender.ts index 14962824f8..9280dbcb0b 100644 --- a/packages/email-plugin/src/sender/nodemailer-email-sender.ts +++ b/packages/email-plugin/src/sender/nodemailer-email-sender.ts @@ -76,7 +76,9 @@ export class NodemailerEmailSender implements EmailSender { } private getSmtpTransport(options: SMTPTransportOptions) { - if (!this._smtpTransport) { + if (!this._smtpTransport || + JSON.stringify(this._smtpTransport?.options) !== JSON.stringify(options) + ) { (options as any).logger = options.logging ? this.createLogger() : false; this._smtpTransport = createTransport(options); } @@ -84,14 +86,19 @@ export class NodemailerEmailSender implements EmailSender { } private getSesTransport(options: SESTransportOptions) { - if (!this._sesTransport) { + if (!this._sesTransport || + JSON.stringify(this._sesTransport?.options) !== JSON.stringify(options) + ) { this._sesTransport = createTransport(options); } return this._sesTransport; } private getSendMailTransport(options: SendmailTransportOptions) { - if (!this._sendMailTransport) { + if (!this._sendMailTransport || + JSON.stringify(this._sendMailTransport?.options) !== + JSON.stringify({ sendmail: true, ...options }) + ) { this._sendMailTransport = createTransport({ sendmail: true, ...options }); } return this._sendMailTransport;