From af3738924e6f56377b1a1df6a117b09c19ce68bf Mon Sep 17 00:00:00 2001 From: Nawaz Dhandala Date: Thu, 22 Jan 2026 20:57:18 +0000 Subject: [PATCH] feat(MailService): add debug logging for SMTP and SendGrid email responses --- .../Notification/Services/MailService.ts | 21 +++++++++++++++++-- 1 file changed, 19 insertions(+), 2 deletions(-) diff --git a/App/FeatureSet/Notification/Services/MailService.ts b/App/FeatureSet/Notification/Services/MailService.ts index b596c45cbb..b1bd582f5f 100755 --- a/App/FeatureSet/Notification/Services/MailService.ts +++ b/App/FeatureSet/Notification/Services/MailService.ts @@ -433,12 +433,16 @@ export default class MailService { try { for (let attempt: number = 1; attempt <= maxRetries; attempt++) { try { - await mailer.sendMail({ + const sendMailResponse = await mailer.sendMail({ from: `${options.emailServer.fromName.toString()} <${options.emailServer.fromEmail.toString()}>`, to: mail.toEmail.toString(), subject: mail.subject, html: mail.body, }); + + logger.debug("SMTP Email Provider Response:"); + logger.debug(JSON.stringify(sendMailResponse, null, 2)); + return; // Success, exit the function } catch (error) { lastError = error; @@ -652,7 +656,20 @@ export default class MailService { emailLog.fromEmail = sendgridConfig.fromEmail; } - await SendgridMail.send(msg); + const sendgridResponse = await SendgridMail.send(msg); + + logger.debug("SendGrid Email Provider Response:"); + logger.debug( + JSON.stringify( + { + statusCode: sendgridResponse[0]?.statusCode, + headers: sendgridResponse[0]?.headers, + body: sendgridResponse[0]?.body, + }, + null, + 2, + ), + ); if (emailLog) { emailLog.status = MailStatus.Success;