diff --git a/gulpfile.js b/gulpfile.js index 5b2b0823c..540c05d6e 100644 --- a/gulpfile.js +++ b/gulpfile.js @@ -158,8 +158,10 @@ gulp.task('services', function() { var auth = require('./services/auth/server/server.js'); var client = require('./services/client/server/server.js'); var server = require('./services/salix/server/server.js'); + var mailer = require('./services/mailer/server.js'); auth.start(); client.start(); server.start(); + mailer.start(); }); diff --git a/services/mailer/Application/config.json b/services/mailer/Application/config.json index f2f0ff057..99da954eb 100644 --- a/services/mailer/Application/config.json +++ b/services/mailer/Application/config.json @@ -10,6 +10,9 @@ "auth": { "user": "", "pass": "" + }, + "tls":{ + "rejectUnauthorized": false } }, "senderMail": "nocontestar@verdnatura.es", @@ -17,7 +20,7 @@ "mysql": { "host": "test-db.verdnatura.es", "port": 3307, - "user": "reports", + "user": "", "password": "", "database": "vn2008" } diff --git a/services/mailer/package.json b/services/mailer/package.json index c78bfc567..87aced84e 100644 --- a/services/mailer/package.json +++ b/services/mailer/package.json @@ -1,13 +1,13 @@ { - "name": "MailServer", - "version": "0.0.1", - "description": "Servidor de envío de correos", - "main": "server.js", - "dependencies": { - "mysql": "^2.13.0", - "express": "^4.15.3", - "body-parser": "^1.17.2", - "nodemailer": "^4.0.1", - "mustache": "^2.3.0" - } -} \ No newline at end of file + "name": "MailServer", + "version": "0.0.1", + "description": "Servidor de envío de correos", + "main": "server.js", + "dependencies": { + "body-parser": "^1.17.2", + "express": "^4.15.3", + "mustache": "^2.3.0", + "mysql": "^2.13.0", + "nodemailer": "^4.0.1" + } +} diff --git a/services/mailer/server.js b/services/mailer/server.js index aa7da128c..448c9b922 100644 --- a/services/mailer/server.js +++ b/services/mailer/server.js @@ -2,7 +2,7 @@ * Módulos necesarios */ var express = require('express'); -var app = express(); +var app = module.exports = express(); var bodyParser = require('body-parser'); var settings = require('./Application/settings.js'); @@ -18,21 +18,20 @@ app.use(bodyParser.urlencoded({extended: true})); // Cargar rutas app.use('/', require('./Application/router.js')); -// Iniciar escucha del servidor -app.listen(settings.port, function() { - // Imprimir cabecera - terminal.printHeader(); - // Escucha SMTP - mail.init(); +app.start = function() { + return app.listen(settings.port, function() { + terminal.printHeader(); + mail.init(); + database.init(); + logger.print(__LOG_INFO, 'Servidor de correo iniciado en el puerto ' + settings.port); + if (settings.debug) { + logger.print(__LOG_WARNING, 'El modo debug está activado'); + } + }); +}; - // Iniciar base de datos - database.init(); - - logger.print(__LOG_INFO, 'Servidor de correo iniciado en el puerto ' + settings.port); - - if (settings.debug) { - logger.print(__LOG_WARNING, 'El modo debug está activado'); - } -}); +if (require.main === module) { + app.start(); +}