- Sending Newsletter, others settings.

This commit is contained in:
Paolo Arena
2019-12-04 18:20:50 +01:00
parent d2dc16b7fb
commit b92655c2e5
5 changed files with 33 additions and 15 deletions

View File

@@ -37,6 +37,9 @@ module.exports = {
// console.log("check EMAIL :" + checkifSendEmail());
if (replyTo === '')
replyTo = mylocalsconf.dataemail.email_reply;
const paramemail = {
message: {
from: mylocalsconf.dataemail.from, // sender address
@@ -66,7 +69,7 @@ module.exports = {
}
}
console.log('paramemail', paramemail);
// console.log('paramemail', paramemail);
const email = new Email(paramemail);
@@ -79,6 +82,7 @@ module.exports = {
locals: mylocalsconf,
})
.then((ris) => {
console.log('ris EMAIL', ris);
return !!ris
})
.catch((err) => {
@@ -408,6 +412,7 @@ module.exports = {
disc_title: await Settings.getValDbSettings(idapp, 'DISC_TITLE'),
height_logo: await Settings.getValDbSettings(idapp, 'HEIGHT_LOGO'),
from: await Settings.getValDbSettings(idapp, 'EMAIL_FROM'),
email_reply: await Settings.getValDbSettings(idapp, 'EMAIL_REPLY', ''),
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'),
@@ -481,11 +486,15 @@ module.exports = {
const smtpTransport = this.getTransport();
let secpause = await Settings.getValDbSettings(idapp, 'MSEC_PAUSE_SEND', process.env.DELAY_SENDEMAIL);
if (secpause > process.env.DELAY_SENDEMAIL)
secpause = process.env.DELAY_SENDEMAIL;
// LOOP USERS EMAIL
for (const user of userstosend) {
if (process.env.DEBUG)
await tools.snooze(10000);
await tools.snooze(30000);
activate = await Newstosent.isActivated(id_newstosent);
@@ -508,7 +517,7 @@ module.exports = {
if (user.lastid_newstosent !== id_newstosent.toString()) {
// Send Email to the User
console.log('-> Invio Email (', mynewsrec.numemail_sent, '/', mynewsrec.numemail_tot, ')');
const esito = this.sendEmail_base('newsletter/' + lang, tools.getAdminEmailByIdApp(idapp), mylocalsconf, '', smtpTransport);
const esito = this.sendEmail_base('newsletter/' + lang, mylocalsconf.emailto, mylocalsconf, mylocalsconf.dataemail.email_reply, smtpTransport);
//Put the result in the database, to check if is sent or not.
const updateml = await MailingList.findOneAndUpdate({
@@ -518,7 +527,7 @@ module.exports = {
//Delay for send email...
await tools.snooze(process.env.DELAY_SENDEMAIL);
await tools.snooze(secpause);
mynewsrec.lastemailsent_Job = new Date();
@@ -597,6 +606,9 @@ module.exports = {
hashemail: tools.getHash(myemail),
};
console.log('myarrevents');
console.table(mylocalsconf.arrevents);
mylocalsconf.dataemail = await this.getdataemail(idapp);
this.replacefields(mylocalsconf);
@@ -604,7 +616,7 @@ module.exports = {
const smtpTransport = this.getTransport();
console.log('-> Invio Email TEST a', mylocalsconf.emailto, 'previewonly', previewonly);
return this.sendEmail_base('newsletter/' + lang, tools.getAdminEmailByIdApp(idapp), mylocalsconf, '', smtpTransport, previewonly);
return this.sendEmail_base('newsletter/' + lang, mylocalsconf.emailto, mylocalsconf, '', smtpTransport, previewonly);
}