email da inviare ai clienti ...
This commit is contained in:
@@ -18,39 +18,35 @@
|
|||||||
- var baseimg = baseurl + '/'
|
- var baseimg = baseurl + '/'
|
||||||
doctype html
|
doctype html
|
||||||
html
|
html
|
||||||
head
|
- if (dataemail.title)
|
||||||
title Calendario Eventi
|
head
|
||||||
|
title dataemail.subject
|
||||||
|
|
||||||
//- import css/scss stylesheets
|
//- import css/scss stylesheets
|
||||||
//- these file names will be replace by gulp with proper css file paths
|
//- these file names will be replace by gulp with proper css file paths
|
||||||
link(rel="stylesheet", href="../sass/basic.scss")
|
link(rel="stylesheet", href="../sass/basic.scss")
|
||||||
link(rel="stylesheet", href="../sass/one/styles.scss")
|
link(rel="stylesheet", href="../sass/one/styles.scss")
|
||||||
|
|
||||||
//- embdedded css allowed, but not sass
|
//- embdedded css allowed, but not sass
|
||||||
style.
|
style.
|
||||||
.red {
|
.red {
|
||||||
background-color: #E84C50;
|
background-color: #E84C50;
|
||||||
}
|
}
|
||||||
|
|
||||||
.full-width {
|
.full-width {
|
||||||
width: 100%;
|
width: 100%;
|
||||||
}
|
}
|
||||||
body(yahoofix)
|
body(yahoofix)
|
||||||
span(id='body_style', style='display:block')
|
span(id='body_style', style='display:block')
|
||||||
table(class="preheader", cellpadding="0", cellspacing="0", width="100%")
|
|
||||||
tr
|
|
||||||
td.webversion
|
|
||||||
p non vedi le immagini?
|
|
||||||
a(href=urlcal) Apri il Calendario
|
|
||||||
|
|
||||||
table(class="topHeader", cellpadding="0", cellspacing="0", width="100%")
|
table(class="topHeader", cellpadding="0", cellspacing="0", width="100%")
|
||||||
tr
|
- if (dataemail.height_logo)
|
||||||
td
|
tr
|
||||||
table(cellpadding="0", cellspacing="0", align="center", summary="")
|
td
|
||||||
tr
|
table(cellpadding="0", cellspacing="0", align="center", summary="")
|
||||||
td.logoContainer
|
tr
|
||||||
a(href=baseurl, title='logo')
|
td.logoContainer
|
||||||
img.logo(src=baseurl+"/images/logo.png", height=dataemail.height_logo)
|
a(href=baseurl, title='logo')
|
||||||
|
img.logo(src=baseurl+"/images/logo.png", height=dataemail.height_logo)
|
||||||
|
|
||||||
tr
|
tr
|
||||||
td.testomail
|
td.testomail
|
||||||
@@ -61,17 +57,17 @@ html
|
|||||||
td.clpromo
|
td.clpromo
|
||||||
p!= dataemail.textpromo
|
p!= dataemail.textpromo
|
||||||
|
|
||||||
- if (dataemail.templ.content)
|
- if (dataemail.templ.content)
|
||||||
table(cellpadding="0", cellspacing="0", width="95%", align="center")
|
table(cellpadding="0", cellspacing="0", width="95%", align="center")
|
||||||
tr
|
tr
|
||||||
td(class="textIniContainer", valign="top")
|
td(class="textIniContainer", valign="top")
|
||||||
p!=dataemail.templ.content
|
p!=dataemail.templ.content
|
||||||
- if (dataemail.templ.img)
|
- if (dataemail.templ.img)
|
||||||
img(src=baseimg + dataemail.templ.img, alt="", class="myimg")
|
img(src=baseimg + dataemail.templ.img, alt="", class="myimg")
|
||||||
- if (dataemail.templ.content2)
|
- if (dataemail.templ.content2)
|
||||||
p!=dataemail.templ.content2
|
p!=dataemail.templ.content2
|
||||||
- if (dataemail.templ.img2)
|
- if (dataemail.templ.img2)
|
||||||
img(src=baseimg + dataemail.templ.img2, alt="", class="myimg")
|
img(src=baseimg + dataemail.templ.img2, alt="", class="myimg")
|
||||||
|
|
||||||
table(cellpadding="0", cellspacing="0", width="640", align="center")
|
table(cellpadding="0", cellspacing="0", width="640", align="center")
|
||||||
- if (dataemail.templ.options.includes('SHOW_EVENTS'))
|
- if (dataemail.templ.options.includes('SHOW_EVENTS'))
|
||||||
@@ -201,10 +197,6 @@ html
|
|||||||
td(class="whitespace", height="20")
|
td(class="whitespace", height="20")
|
||||||
p
|
p
|
||||||
|
|
||||||
tr
|
|
||||||
td(class="whitespace", height="20")
|
|
||||||
p
|
|
||||||
|
|
||||||
// Social Media
|
// Social Media
|
||||||
table.socialMedia(cellpadding="0", cellspacing="0", width="100%", summary="", border="0", align="center")
|
table.socialMedia(cellpadding="0", cellspacing="0", width="100%", summary="", border="0", align="center")
|
||||||
tr
|
tr
|
||||||
|
|||||||
@@ -2,7 +2,7 @@
|
|||||||
body, #body_style {
|
body, #body_style {
|
||||||
margin: 0;
|
margin: 0;
|
||||||
padding: 0;
|
padding: 0;
|
||||||
background: #E9F2F9;
|
background: #E9F2F9 !important;
|
||||||
color: #5b656e;
|
color: #5b656e;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -235,7 +235,7 @@ module.exports.getOrdersCartByQuery = async function (query) {
|
|||||||
.populate({
|
.populate({
|
||||||
path: 'userId',
|
path: 'userId',
|
||||||
model: 'User',
|
model: 'User',
|
||||||
select: '_id name surname username profile'
|
select: '_id name surname username profile email lang'
|
||||||
})
|
})
|
||||||
.lean();
|
.lean();
|
||||||
|
|
||||||
|
|||||||
@@ -22,14 +22,15 @@ const Product = require('../models/product');
|
|||||||
const Order = require('../models/order');
|
const Order = require('../models/order');
|
||||||
const Variant = require('../models/variant');
|
const Variant = require('../models/variant');
|
||||||
|
|
||||||
|
const sendemail = require('../sendemail');
|
||||||
const CartClass = require('../modules/Cart')
|
const CartClass = require('../modules/Cart')
|
||||||
const Cart = require('../models/cart');
|
const Cart = require('../models/cart');
|
||||||
const OrdersCart = require('../models/orderscart');
|
const OrdersCart = require('../models/orderscart');
|
||||||
|
|
||||||
//GET orders
|
//GET orders
|
||||||
router.get('/:userId', authenticate, function (req, res, next) {
|
router.get('/:userId', authenticate, function (req, res, next) {
|
||||||
let userId = req.body.userId
|
let userId = req.body.userId;
|
||||||
let idapp = req.body.idapp
|
let idapp = req.body.idapp;
|
||||||
OrdersCart.getOrdersCartByUserId(userId, idapp, 0, false)
|
OrdersCart.getOrdersCartByUserId(userId, idapp, 0, false)
|
||||||
.then((cart) => {
|
.then((cart) => {
|
||||||
|
|
||||||
@@ -39,6 +40,36 @@ router.get('/:userId', authenticate, function (req, res, next) {
|
|||||||
res.status(400).send(e);
|
res.status(400).send(e);
|
||||||
})
|
})
|
||||||
|
|
||||||
})
|
});
|
||||||
|
|
||||||
|
router.post('/sendmail', authenticate, async function (req, res, next) {
|
||||||
|
const idOrdersCart = req.body.idOrdersCart;
|
||||||
|
const idapp = req.body.idapp;
|
||||||
|
const test = req.body.test;
|
||||||
|
const previewonly = req.body.previewonly;
|
||||||
|
const templemail_id = req.body.templemail_id;
|
||||||
|
|
||||||
|
try {
|
||||||
|
// Invia Email
|
||||||
|
let myOrderCart = await OrdersCart.getOrdersCartById(idOrdersCart);
|
||||||
|
if (myOrderCart) {
|
||||||
|
const userto = myOrderCart.user;
|
||||||
|
let emailto = userto.email;
|
||||||
|
|
||||||
|
if (userto && emailto) {
|
||||||
|
const emailsend = await sendemail.sendEmail_byTemplate (idapp, userto, previewonly, emailto, templemail_id, test);
|
||||||
|
|
||||||
|
return res.send({ code: server_constants.RIS_CODE_OK, emailsend });
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return res.send({ code: server_constants.RIS_CODE_OK, emailsend: false });
|
||||||
|
|
||||||
|
} catch (e) {
|
||||||
|
console.error('err:', e);
|
||||||
|
res.status(400).send(e);
|
||||||
|
}
|
||||||
|
|
||||||
|
});
|
||||||
|
|
||||||
module.exports = router;
|
module.exports = router;
|
||||||
|
|||||||
@@ -62,6 +62,9 @@ module.exports = {
|
|||||||
if (replyTo === '')
|
if (replyTo === '')
|
||||||
replyTo = mylocalsconf.dataemail.email_reply;
|
replyTo = mylocalsconf.dataemail.email_reply;
|
||||||
|
|
||||||
|
if (!replyTo)
|
||||||
|
replyTo = '';
|
||||||
|
|
||||||
const paramemail = {
|
const paramemail = {
|
||||||
message: {
|
message: {
|
||||||
from: mylocalsconf.dataemail.from, // sender address
|
from: mylocalsconf.dataemail.from, // sender address
|
||||||
@@ -645,7 +648,7 @@ module.exports = {
|
|||||||
return mylocalsconf;
|
return mylocalsconf;
|
||||||
},
|
},
|
||||||
|
|
||||||
getdataemail: async (idapp) => {
|
getdataemail: async (idapp, templemail_id) => {
|
||||||
// console.log('getdataemail');
|
// console.log('getdataemail');
|
||||||
const mydata = {
|
const mydata = {
|
||||||
content_after_events: await Settings.getValDbSettings(idapp, 'TEXT_AFTER_EV'),
|
content_after_events: await Settings.getValDbSettings(idapp, 'TEXT_AFTER_EV'),
|
||||||
@@ -667,7 +670,7 @@ module.exports = {
|
|||||||
pwd_from: await Settings.getValDbSettings(idapp, 'PWD_FROM'),
|
pwd_from: await Settings.getValDbSettings(idapp, 'PWD_FROM'),
|
||||||
email_service: await Settings.getValDbSettings(idapp, 'EMAIL_SERVICE_SEND'),
|
email_service: await Settings.getValDbSettings(idapp, 'EMAIL_SERVICE_SEND'),
|
||||||
email_port: await Settings.getValDbSettings(idapp, 'EMAIL_PORT'),
|
email_port: await Settings.getValDbSettings(idapp, 'EMAIL_PORT'),
|
||||||
templemail_id: await Settings.getValDbSettings(idapp, 'TEMPLEMAIL_ID'),
|
templemail_id: templemail_id ? templemail_id : await Settings.getValDbSettings(idapp, 'TEMPLEMAIL_ID'),
|
||||||
};
|
};
|
||||||
|
|
||||||
// console.log(mydata.templemail_id);
|
// console.log(mydata.templemail_id);
|
||||||
@@ -990,7 +993,6 @@ module.exports = {
|
|||||||
arrevents: myarrevents,
|
arrevents: myarrevents,
|
||||||
name: 'TestNome',
|
name: 'TestNome',
|
||||||
surname: 'TestCognome',
|
surname: 'TestCognome',
|
||||||
subject: '',
|
|
||||||
emailto: myemail,
|
emailto: myemail,
|
||||||
baseurl: tools.getHostByIdApp(idapp),
|
baseurl: tools.getHostByIdApp(idapp),
|
||||||
hashemail: tools.getHash(myemail),
|
hashemail: tools.getHash(myemail),
|
||||||
@@ -1001,6 +1003,8 @@ module.exports = {
|
|||||||
|
|
||||||
mylocalsconf.dataemail = await this.getdataemail(idapp);
|
mylocalsconf.dataemail = await this.getdataemail(idapp);
|
||||||
|
|
||||||
|
mylocalsconf.dataemail.subject = mylocalsconf.dataemail && mylocalsconf.dataemail.templ ? mylocalsconf.dataemail.templ.subject : '',
|
||||||
|
|
||||||
this.replacefields(mylocalsconf);
|
this.replacefields(mylocalsconf);
|
||||||
|
|
||||||
const smtpTransport = this.getTransport(mylocalsconf);
|
const smtpTransport = this.getTransport(mylocalsconf);
|
||||||
@@ -1013,6 +1017,45 @@ module.exports = {
|
|||||||
|
|
||||||
},
|
},
|
||||||
|
|
||||||
|
sendEmail_byTemplate: async function (idapp, userto, previewonly, emailto, templemail_id, test) {
|
||||||
|
|
||||||
|
// const myarrevents = await MyEvent.getLastEvents(idapp);
|
||||||
|
const myemail = emailto;
|
||||||
|
if (myemail) {
|
||||||
|
let mylocalsconf = {
|
||||||
|
idapp,
|
||||||
|
locale: userto.lang,
|
||||||
|
nomeapp: tools.getNomeAppByIdApp(idapp),
|
||||||
|
name: userto.name,
|
||||||
|
surname: userto.surname,
|
||||||
|
emailto: myemail,
|
||||||
|
baseurl: tools.getHostByIdApp(idapp),
|
||||||
|
hashemail: tools.getHash(myemail),
|
||||||
|
};
|
||||||
|
|
||||||
|
if (test) {
|
||||||
|
mylocalsconf.emailto = await Settings.getValDbSettings(idapp, 'EMAIL_TEST');
|
||||||
|
}
|
||||||
|
|
||||||
|
mylocalsconf.dataemail = await this.getdataemail(idapp, templemail_id);
|
||||||
|
|
||||||
|
this.replacefields(mylocalsconf);
|
||||||
|
|
||||||
|
mylocalsconf.subject = mylocalsconf.dataemail.templ.subject;
|
||||||
|
|
||||||
|
const smtpTransport = this.getTransport(mylocalsconf);
|
||||||
|
|
||||||
|
console.log('-> Invio Email ' + mylocalsconf.subject + ' a', mylocalsconf.emailto, 'in corso...');
|
||||||
|
const risult = await this.sendEmail_base('newsletter/' + userto.lang, mylocalsconf.emailto, mylocalsconf, '', smtpTransport, previewonly);
|
||||||
|
console.log(' ...email inviata?', risult);
|
||||||
|
|
||||||
|
return risult;
|
||||||
|
}
|
||||||
|
|
||||||
|
return false;
|
||||||
|
|
||||||
|
},
|
||||||
|
|
||||||
testemailHtml: async function (idapp, lang, email, myuser) {
|
testemailHtml: async function (idapp, lang, email, myuser) {
|
||||||
|
|
||||||
let mytitle = 'Prova msg';
|
let mytitle = 'Prova msg';
|
||||||
|
|||||||
Reference in New Issue
Block a user