- Tolto Zoom e Sogni come requisiti
- Corretto Email con HTML che si visualizzavano tutti i caratteri HTML...
This commit is contained in:
@@ -105,23 +105,27 @@ module.exports = {
|
||||
});
|
||||
},
|
||||
|
||||
sendEmail_Normale: function (to, subject, html, replyTo) {
|
||||
sendEmail_Normale: async function (to, subject, html, replyTo) {
|
||||
|
||||
// setup e-mail data with unicode symbols
|
||||
var mailOptions = {
|
||||
from: tools.getEmailByIdApp(mylocalsconf.idapp), // sender address
|
||||
dataemail: await this.getdataemail(idapp),
|
||||
to: to,
|
||||
generateTextFromHTML: true,
|
||||
subject: subject,
|
||||
html: html,
|
||||
};
|
||||
|
||||
|
||||
if (replyTo)
|
||||
mailOptions['reply-to'] = replyTo;
|
||||
|
||||
if (process.env.SEND_EMAIL === 1) {
|
||||
const smtpTransport = this.getTransport(mylocalsconf);
|
||||
|
||||
if (process.env.SEND_EMAIL === "1") {
|
||||
// console.log("SEND EMAIL...");
|
||||
// send mail with defined transport object
|
||||
// send mail with defined transport object
|
||||
smtpTransport.sendMail(mailOptions, function (error, response) {
|
||||
if (error) {
|
||||
console.log("Email Inviata ERRORE RISPOSTA: " + error);
|
||||
@@ -328,7 +332,8 @@ module.exports = {
|
||||
if (!!mylocalsconf.dataemail.emailtitle && !!mylocalsconf.dataemail.emailbody) {
|
||||
const replyto = tools.getreplyToEmailByIdApp(idapp);
|
||||
|
||||
return this.sendEmail_base('standard', emailto, mylocalsconf, replyto);
|
||||
//return this.sendEmail_base('standard', emailto, mylocalsconf, replyto);
|
||||
return await this.sendEmail_Normale(emailto, mylocalsconf.dataemail.emailtitle, mylocalsconf.dataemail.emailbody, replyto);
|
||||
}
|
||||
|
||||
// Send Email also to the Admin
|
||||
@@ -490,7 +495,7 @@ module.exports = {
|
||||
// Create Transport
|
||||
let smtpTransport = null;
|
||||
|
||||
if (mylocalsconf.dataemail.email_service !== 'gmail' && mylocalsconf.dataemail.email_service !== undefined) {
|
||||
if (mylocalsconf.dataemail.email_service !== 'gmail' && mylocalsconf.dataemail.email_service !== undefined && mylocalsconf.dataemail.email_service !== "") {
|
||||
smtpTransport = nodemailer.createTransport({
|
||||
host: mylocalsconf.dataemail.email_service,
|
||||
port: mylocalsconf.dataemail.email_port,
|
||||
@@ -500,21 +505,24 @@ module.exports = {
|
||||
}
|
||||
});
|
||||
} else if (mylocalsconf.dataemail.email_service === 'gmail' && mylocalsconf.dataemail.email_service !== undefined) {
|
||||
smtpTransport = {
|
||||
|
||||
//smtpTransport = {
|
||||
smtpTransport = nodemailer.createTransport({
|
||||
service: 'gmail', //'Gmail',
|
||||
auth: {
|
||||
user: mylocalsconf.dataemail.from,
|
||||
pass: mylocalsconf.dataemail.pwd_from
|
||||
}
|
||||
};
|
||||
});
|
||||
} else {
|
||||
smtpTransport = {
|
||||
// smtpTransport = {
|
||||
smtpTransport = nodemailer.createTransport({
|
||||
service: 'gmail',
|
||||
auth: {
|
||||
user: tools.getEmailByIdApp(mylocalsconf.idapp),
|
||||
pass: tools.getPwdByIdApp(mylocalsconf.idapp)
|
||||
}
|
||||
};
|
||||
});
|
||||
}
|
||||
|
||||
return smtpTransport;
|
||||
@@ -719,6 +727,28 @@ module.exports = {
|
||||
console.log('-> Invio Email TEST a', mylocalsconf.emailto, 'previewonly', previewonly);
|
||||
return this.sendEmail_base('newsletter/' + lang, mylocalsconf.emailto, mylocalsconf, '', smtpTransport, previewonly);
|
||||
|
||||
},
|
||||
|
||||
testemailHtml: async function (idapp, lang, email, myuser) {
|
||||
|
||||
|
||||
mytitle = 'Prova msg'
|
||||
messaggio = '<br><b>Ciao!</b><div>Come stai?</div><br>Tutto Bene?<br><a href="https://ayni.gifteconomy.app/">Prova Link</a><br><i>Corsivo</i></i> ';
|
||||
|
||||
/*const htmlToText = require('html-to-text');
|
||||
|
||||
messaggio = htmlToText.fromString(messaggio, {
|
||||
wordwrap: 80,
|
||||
preserveNewlines: true,
|
||||
singleNewLineParagraphs: true
|
||||
});
|
||||
*/
|
||||
|
||||
return await this.sendEmail_ByText(lang, email, myuser, idapp, {
|
||||
emailbody: messaggio,
|
||||
emailtitle: mytitle
|
||||
});
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user