email da inviare ai clienti ...
This commit is contained in:
@@ -62,6 +62,9 @@ module.exports = {
|
||||
if (replyTo === '')
|
||||
replyTo = mylocalsconf.dataemail.email_reply;
|
||||
|
||||
if (!replyTo)
|
||||
replyTo = '';
|
||||
|
||||
const paramemail = {
|
||||
message: {
|
||||
from: mylocalsconf.dataemail.from, // sender address
|
||||
@@ -645,7 +648,7 @@ module.exports = {
|
||||
return mylocalsconf;
|
||||
},
|
||||
|
||||
getdataemail: async (idapp) => {
|
||||
getdataemail: async (idapp, templemail_id) => {
|
||||
// console.log('getdataemail');
|
||||
const mydata = {
|
||||
content_after_events: await Settings.getValDbSettings(idapp, 'TEXT_AFTER_EV'),
|
||||
@@ -667,7 +670,7 @@ module.exports = {
|
||||
pwd_from: await Settings.getValDbSettings(idapp, 'PWD_FROM'),
|
||||
email_service: await Settings.getValDbSettings(idapp, 'EMAIL_SERVICE_SEND'),
|
||||
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);
|
||||
@@ -990,7 +993,6 @@ module.exports = {
|
||||
arrevents: myarrevents,
|
||||
name: 'TestNome',
|
||||
surname: 'TestCognome',
|
||||
subject: '',
|
||||
emailto: myemail,
|
||||
baseurl: tools.getHostByIdApp(idapp),
|
||||
hashemail: tools.getHash(myemail),
|
||||
@@ -1001,6 +1003,8 @@ module.exports = {
|
||||
|
||||
mylocalsconf.dataemail = await this.getdataemail(idapp);
|
||||
|
||||
mylocalsconf.dataemail.subject = mylocalsconf.dataemail && mylocalsconf.dataemail.templ ? mylocalsconf.dataemail.templ.subject : '',
|
||||
|
||||
this.replacefields(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) {
|
||||
|
||||
let mytitle = 'Prova msg';
|
||||
|
||||
Reference in New Issue
Block a user