diff --git a/print/core/smtp.js b/print/core/smtp.js index 276b85401..8c07e7eca 100644 --- a/print/core/smtp.js +++ b/print/core/smtp.js @@ -10,16 +10,17 @@ module.exports = { async send(options) { options.from = `${config.app.senderName} <${config.app.senderEmail}>`; - if (!process.env.NODE_ENV) - options.to = config.app.senderEmail; + const env = process.env.NODE_ENV; + const canSend = env === 'production' || !env || options.force; - if (process.env.NODE_ENV !== 'production' && !options.force) { + if (!canSend || !config.smtp.auth.user) { const notProductionError = {message: 'This not production, this email not sended'}; await this.mailLog(options, notProductionError); + return Promise.resolve(true); } - if (!config.smtp.auth.user) - return Promise.resolve(true); + if (!env) + options.to = config.app.senderEmail; let res; let error;