diff --git a/Server/service/emailService.js b/Server/service/emailService.js index 40641ef42..519162ba0 100644 --- a/Server/service/emailService.js +++ b/Server/service/emailService.js @@ -44,7 +44,7 @@ class EmailService { const templateContent = this.fs.readFileSync(templatePath, "utf8"); return this.compile(templateContent); } catch (error) { - logger.error("Error loading Email templates", { + this.logger.error("Error loading Email templates", { error, service: this.SERVICE_NAME, }); @@ -102,7 +102,7 @@ class EmailService { const html = await this.mjml2html(mjml); return html.html; } catch (error) { - logger.error("Error building Email HTML", { + this.logger.error("Error building Email HTML", { error, service: SERVICE_NAME, }); @@ -118,26 +118,15 @@ class EmailService { }); return info; } catch (error) { - logger.error("Error sending Email", { + this.logger.error("Error sending Email", { error, service: SERVICE_NAME, }); } }; - - try { - const info = await sendEmail(to, subject, await buildHtml(template, context)); - return info.messageId; - } catch (error) { - error.service = SERVICE_NAME; - if (error.method === undefined) { - error.method = "buildAndSendEmail"; - } - logger.error("Error building and sending Email", { - error, - service: SERVICE_NAME, - }); - } + const html = await buildHtml(template, context); + const info = await sendEmail(to, subject, html); + return info?.messageId; }; } export default EmailService;