From a8fafacb828bdbed02007b768f47ac585d02f9c2 Mon Sep 17 00:00:00 2001 From: alexm Date: Tue, 20 Jun 2023 15:06:02 +0200 Subject: [PATCH] refs #5475 send email force --- loopback/common/methods/vn-model/printService.js | 2 +- print/core/email.js | 7 ++++--- print/core/smtp.js | 4 ++-- 3 files changed, 7 insertions(+), 6 deletions(-) diff --git a/loopback/common/methods/vn-model/printService.js b/loopback/common/methods/vn-model/printService.js index 5cd571d4c..807613653 100644 --- a/loopback/common/methods/vn-model/printService.js +++ b/loopback/common/methods/vn-model/printService.js @@ -52,6 +52,6 @@ module.exports = Self => { const email = new Email(templateName, params); - return email.send(); + return email.send({force: true}); }; }; diff --git a/print/core/email.js b/print/core/email.js index 6e96f5c2e..2d1ee42cf 100644 --- a/print/core/email.js +++ b/print/core/email.js @@ -63,12 +63,12 @@ class Email extends Component { await getAttachments(componentPath, component.attachments); if (component.components) - await getSubcomponentAttachments(component) + await getSubcomponentAttachments(component); } } } - await getSubcomponentAttachments(instance) + await getSubcomponentAttachments(instance); if (this.attachments) await getAttachments(this.path, this.attachments); @@ -84,7 +84,8 @@ class Email extends Component { replyTo: this.args.replyTo || '', subject: localeSubject, html: rendered, - attachments: attachments + attachments: attachments, + force: options.force }; return smtp.send(mailOptions); diff --git a/print/core/smtp.js b/print/core/smtp.js index 61b115b5a..50fe55986 100644 --- a/print/core/smtp.js +++ b/print/core/smtp.js @@ -10,7 +10,8 @@ module.exports = { async send(options) { options.from = `${config.app.senderName} <${config.app.senderEmail}>`; - + console.log(process.env.NODE_ENV !== 'production' && !options.force); + console.log(process.env.NODE_ENV !== 'production', !options.force); if (process.env.NODE_ENV !== 'production') { const notProductionError = {message: 'This not production, this email not sended'}; await this.mailLog(options, notProductionError); @@ -19,7 +20,6 @@ module.exports = { options.to = config.app.senderEmail; } - let error; return this.transporter.sendMail(options).catch(err => { error = err;