emails - do not send them when testing
MODIFY
src/notification/email/EMailNotificationTask.ts
src/notification/email/EMailNotificationTask.ts
@@ -295,6 +295,19 @@ export default class EMailNotificationTask implements NotificationTask {
{ data: email.html, alternative: true }
]
});
+ if (Utils.isDevelopmentEnv()) {
+ // Do not send mail in Dev mode
+ await Logging.logDebug({
+ tenantID: tenant.id ? tenant.id : Constants.DEFAULT_TENANT_ID,
+ action: ServerAction.EMAIL_NOTIFICATION,
+ module: MODULE_NAME, method: 'sendEmail',
+ actionOnUser: user,
+ message: `Email Sent: '${email.subject}'`,
+ detailedMessages: {
+ content: email.html // Only log the email content when running automated tests
+ }
+ });
+ } else {
try {
// Get the SMTP client
const smtpClient = this.getSMTPClient(useSmtpClientBackup);
@@ -315,7 +328,6 @@ export default class EMailNotificationTask implements NotificationTask {
from: rfc2047.decode(messageSent.header.from.toString()),
to: rfc2047.decode(messageSent.header.to.toString()),
subject: rfc2047.decode(messageSent.header.subject),
- // content: email.html
}
});
} catch (error) {
@@ -336,7 +348,6 @@ export default class EMailNotificationTask implements NotificationTask {
subject: rfc2047.decode(messageToSend.header.subject),
smtpError: error.smtp,
error: error.stack,
- // content: email.html
}
});
// For Unit Tests only: Tenant is deleted and email is not known thus this Logging statement is always failing with an invalid Tenant
@@ -368,6 +379,7 @@ export default class EMailNotificationTask implements NotificationTask {
}
}
}
+ }
private async sendSmartEmail(prefix: string, context: any, recipient: User, tenant: Tenant, severity: NotificationSeverity, optionalComponents: string[] = []): Promise<EmailNotificationMessage> {
// Select the i18n source according to the recipient locale

emails - do not send them when testing