Deshabilitada conexión SMTP en entorno test

This commit is contained in:
Joan Sanchez 2018-01-03 13:41:22 +01:00
parent 492902e637
commit ca25280743
1 changed files with 6 additions and 2 deletions

View File

@ -12,6 +12,8 @@ module.exports = {
* Load mail config. * Load mail config.
*/ */
init: function() { init: function() {
if (process.env.NODE_ENV == 'test')
return;
this.transporter = nodemailer.createTransport(config.smtp); this.transporter = nodemailer.createTransport(config.smtp);
@ -35,6 +37,9 @@ module.exports = {
* @param {Object} cb - Callback * @param {Object} cb - Callback
*/ */
send: function(recipient, subject, body, attachments, params, cb) { send: function(recipient, subject, body, attachments, params, cb) {
if (process.env.NODE_ENV == 'test')
return;
let mailOptions = { let mailOptions = {
from: '"' + config.app.senderName + '" <' + config.app.senderMail + '>', from: '"' + config.app.senderName + '" <' + config.app.senderMail + '>',
to: recipient, to: recipient,
@ -43,9 +48,8 @@ module.exports = {
attachments attachments
}; };
if (config.app.debug) { if (process.env.NODE_ENV != 'production')
mailOptions.to = config.smtp.testEmail; mailOptions.to = config.smtp.testEmail;
}
this.transporter.sendMail(mailOptions, (error, info) => { this.transporter.sendMail(mailOptions, (error, info) => {
try { try {