Quita contraseña de smtp.test.json

This commit is contained in:
Joan Sanchez 2017-10-25 00:38:02 +02:00
parent 7b2506df80
commit 13981ae023
9 changed files with 181 additions and 12 deletions

View File

@ -3,7 +3,6 @@
"port": 465,
"secure": true,
"auth": {
"id": 10240,
"user": "noreply",
"pass": ""
},

View File

@ -3,9 +3,8 @@
"port": 465,
"secure": true,
"auth": {
"id": 10240,
"user": "nocontestar",
"pass": "ub606cux7op"
"pass": ""
},
"tls": {
"rejectUnauthorized": false

View File

@ -46,16 +46,20 @@ module.exports = {
}
this.transporter.sendMail(mailOptions, (error, info) => {
let status = (error ? error.message : 'OK');
this.log(params.sender, params.recipient, recipient, subject, body, params.message, status);
try {
let status = (error ? error.message : 'OK');
this.log(params.sender, params.recipient, recipient, subject, body, params.message, status);
if (error)
return cb(new Error('Email not sent: ' + error));
if (error)
return cb(new Error('Email not sent: ' + error));
if (settings.app().debug)
console.log('Mail sent ' + info.messageId + ' [' + info.response + ']');
if (settings.app().debug)
console.log('Mail sent ' + info.messageId + ' [' + info.response + ']');
cb();
cb();
} catch(e) {
throw e;
}
});
},

View File

@ -2,6 +2,7 @@ var express = require('express');
var router = new express.Router();
var mail = require('../mail.js');
var template = require('../template.js');
var httpRequest = require('request');
// Payment method changes
router.post('/payment-update/:clientId', function(request, response, next) {
@ -43,4 +44,42 @@ router.post('/client-welcome/:clientId', function(request, response, next) {
});
});
// Client welcome preview
router.get('/client-welcome/:clientId', function(request, response, next) {
template.get('client-welcome', {recipient: request.params.clientId}, true, (error, result) => {
if (error)
return response.status(400).json({message: error.message});
response.send(result.body);
});
});
// Sepa core
router.post('/sepa-core/:clientId', function(request, response, next) {
var options = {
url: 'http://localhost:3008/manuscript/sepa-core/7422',
method: 'POST',
headers: {
'authorization': request.headers.authorization
}
}
let httpStream = httpRequest(options, function(error, httpResponse, body) {
if (error)
return response.status(400).json({message: httpResponse.message});
});
if (httpStream)
mail.send('joan@verdnatura.es', 'Correu de prova', 'test message', [{filename: 'test.pdf', content: httpStream}], function(error, result) {
if (error)
return response.status(400).json({message: error.message});
});
/* mail.sendWithTemplate('sepa-core', {recipient: request.params.clientId}, error => {
if (error)
return response.status(400).json({message: error.message});
return response.json();
}); */
});
module.exports = router;

View File

@ -28,12 +28,12 @@ module.exports = class ClientWelcome {
get salesPersonName() {
if (this.name)
return `<div>${this._.salesPersonNameText}: <strong style="font-size: 20px">${this.name}</strong></div>`;
return `<div>${this._.salesPersonNameText}: <strong>${this.name}</strong></div>`;
}
get salesPersonPhone() {
if (this.phone)
return `<div>${this._.salesPersonPhoneText}: <strong style="font-size: 20px">${format.phone(this.phone)}</strong></div>`;
return `<div>${this._.salesPersonPhoneText}: <strong>${format.phone(this.phone)}</strong></div>`;
}
get salesPersonEmail() {

View File

@ -0,0 +1 @@
[]

View File

@ -0,0 +1,74 @@
<!DOCTYPE html>
<html lang="es">
<head>
<title>{{_.subject}}</title>
<meta charset="utf8"/>
</head>
<body>
<div class="wrapper">
<div class="container">
<!-- Banner block -->
<div class="banner">
<a href="https://www.verdnatura.es"/><img src="cid:header.png" alt="VerdNatura"/></a>
</div>
<!-- Banner block end -->
<!-- Title block -->
<div class="title">
<h1>{{_.title}}</h1>
</div>
<!-- Title block end -->
<!-- Mail body block -->
<div class="body">
<p style="text-align: justify">{{_.dear}},</p>
<p style="text-align: justify">{{_.bodyDescription}}</p>
</div>
<!-- Mail body block end -->
<!-- Action button block -->
<div class="buttons">
<a href="https://www.verdnatura.es" target="_blank"><div class="btn">
<span class="text">{{_.actionButton}}</span>
<span class="icon"><img src="cid:action.png"/></span>
</div></a><a href="https://goo.gl/forms/j8WSL151ZW6QtlT72" target="_blank"><div class="btn">
<span class="text">{{_.infoButton}}</span>
<span class="icon"><img src="cid:info.png"/></span>
</div></a>
</div>
<!-- Action button block -->
<!-- Networks block -->
<div class="footer">
<a href="https://www.facebook.com/Verdnatura" target="_blank">
<img src="cid:facebook.png" alt="Facebook"/>
</a>
<a href="https://www.twitter.com/Verdnatura" target="_blank">
<img src="cid:twitter.png" alt="Twitter"/>
</a>
<a href="https://www.youtube.com/Verdnatura" target="_blank">
<img src="cid:youtube.png" alt="Youtube"/>
</a>
<a href="https://www.pinterest.com/Verdnatura" target="_blank">
<img src="cid:pinterest.png" alt="Pinterest"/>
</a>
<a href="https://www.instagram.com/Verdnatura" target="_blank">
<img src="cid:instagram.png" alt="Instagram"/>
</a>
<a href="https://www.linkedin.com/company/verdnatura" target="_blank">
<img src="cid:linkedin.png" alt="Linkedin"/>
</a>
</div>
<!-- Networks block end -->
<!-- Privacy block -->
<div class="privacy">
<p style="text-align: justify">{{_.fiscalAddress}}</p>
<p style="text-align: justify">{{_.privacy}}</p>
<p style="text-align: justify">{{_.privacyLaw}}</p>
</div>
<!-- Privacy block end -->
</div>
</div>
</body>
</html>

View File

@ -0,0 +1,11 @@
{
"subject": "Instalación y configuración de impresora",
"title": "¡GRACIAS POR SU CONFIANZA!",
"dear": "Estimado cliente",
"bodyDescription": "A continuación le adjuntamos el documento de domicilación de datos bancarios.",
"actionButton": "Visita nuestra Web",
"infoButton": "Ayúdanos a mejorar",
"fiscalAddress": "VERDNATURA LEVANTE SL, B97367486 Avda. Espioca, 100, 46460 Silla _ www.verdnatura.es _ clientes@verdnatura.es",
"privacy": "- AVISO - Este mensaje es privado y confidencial, y debe ser utilizado exclusivamente por la persona destinataria del mismo. Si usted ha recibido este mensaje por error, le rogamos lo comunique al remitente y borre dicho mensaje y cualquier documento adjunto que pudiera contener. Verdnatura Levante SL no renuncia a la confidencialidad ni a ningún privilegio por causa de transmisión errónea o mal funcionamiento. Igualmente no se hace responsable de los cambios, alteraciones, errores u omisiones que pudieran hacerse al mensaje una vez enviado.",
"privacyLaw": "En cumplimiento de lo dispuesto en la Ley Orgánica 15/1999, de Protección de Datos de Carácter Personal, le comunicamos que los datos personales que facilite se incluirán en ficheros automatizados de VERDNATURA LEVANTE S.L., pudiendo en todo momento ejercitar los derechos de acceso, rectificación, cancelación y oposición, comunicándolo por escrito al domicilio social de la entidad. La finalidad del fichero es la gestión administrativa, contabilidad, y facturación."
}

View File

@ -0,0 +1,42 @@
var path = require('path');
var database = require(path.join(__dirname, '../../database.js'));
var format = require(path.join(__dirname, '../../util/format.js'));
module.exports = class SepaCore {
getData(params, cb) {
let query = `SELECT
CONCAT(w.name, ' ', w.firstName) name,
w.phone AS phone,
CONCAT(u.name, '@verdnatura.es') AS email,
LOWER(ct.code) countryCode,
c.email recipient
FROM client c
LEFT JOIN worker w ON w.id = c.workerFk
LEFT JOIN account.user u ON u.id = w.userFk
JOIN country ct ON ct.id = c.countryFk
WHERE c.id = ?`;
database.pool.query(query, [params.recipient], (error, result) => {
if (error || result.length == 0)
return cb(new Error('No template data found'));
Object.assign(this, result[0]);
cb();
});
}
get salesPersonName() {
if (this.name)
return `<div>${this._.salesPersonNameText}: <strong>${this.name}</strong></div>`;
}
get salesPersonPhone() {
if (this.phone)
return `<div>${this._.salesPersonPhoneText}: <strong>${format.phone(this.phone)}</strong></div>`;
}
get salesPersonEmail() {
if (this.email)
return `<div>${this._.salesPersonEmailText}: ` +
`<strong><a href="mailto:${this.email}" target="_blank" style="color:#8dba25">${this.email}</strong></div>`;
}
};