mailer: log error and do not throw

this suppresses eventlog exceptions when mail is down or the
mail is rejected because outbound is disabled.

in apphealthmonitor, we hit a case where eventlog entries are
continuously added since mailer was not sending emails. the health
state of the app is never switched because mail sending failed.
This commit is contained in:
Girish Ramakrishnan
2025-08-06 09:55:53 +02:00
parent a7ffc8a172
commit 3d4b3edc3a

View File

@@ -66,12 +66,14 @@ async function sendMail(mailOptions) {
auth: {
user: mailOptions.authUser || `no-reply@${dashboardDomain}`,
pass: data.relayToken
}
},
logger: false,
debug: false // set to true for smtp logs
});
const [error] = await safe(transport.sendMail(mailOptions));
if (error) throw new BoxError(BoxError.EXTERNAL_ERROR, error);
debug(`Email "${mailOptions.subject}" sent to ${mailOptions.to}`);
if (error) debug(`Error sending Email "${mailOptions.subject}" to ${mailOptions.to}: ${error.message}`);
else debug(`Email "${mailOptions.subject}" sent to ${mailOptions.to}`);
}
function render(templateFile, params, translationAssets) {