send message with BAM

This commit is contained in:
Manuel Romero
2021-02-05 17:16:25 +01:00
parent 0e1817947e
commit 9374a60e2a
2 changed files with 18 additions and 32 deletions

View File

@@ -30,17 +30,25 @@ if ( process.env.GMAIL_USERNAME && process.env.GMAIL_PASSWORD ) {
async function _doSend(to, subject, htmlText) {
// send mail with defined transport object
let info = await transporter.sendMail( {
from: FROM, // sender address
to: to, // list of receivers
subject: subject, // Subject line
text: subject, // plain text body
html: htmlText // html body
} );
console.log('SendEmail# message id ('+info.messageId+') sent to: ' + to);
try {
return info;
let info = await transporter.sendMail( {
from: FROM, // sender address
to: to, // list of receivers
subject: subject, // Subject line
text: subject, // plain text body
html: htmlText // html body
} );
console.log('SendEmail# message id ('+info.messageId+') sent to: ' + to);
return info;
} catch (err) {
console.log('SendEmail# ERROR!! -> could not send email to: ' + to);
console.log(err);
}
}
function _getCommonDetails(provision, scenario){

View File

@@ -1,7 +1,4 @@
'use strict';
const nodemailer = require('nodemailer');
const FROM = '"Qlik" <no-reply@qlik.com>';
var transporter;
const axios = require('axios');
const https = require("https");
@@ -10,25 +7,6 @@ const FOOTER = `<div style="color:#404040;font-size:16px;margin:30px 0px">
<p style="margin:0px">Check it out at <a href="${HOSTNAME_URL}">${HOSTNAME_URL}</a></p>
</div>`;
if ( process.env.GMAIL_USERNAME && process.env.GMAIL_PASSWORD ) {
//GMAIL
transporter = nodemailer.createTransport({
service: 'gmail',
port: 587,
secure: false,
auth: {
user: process.env.GMAIL_USERNAME,
pass: process.env.GMAIL_PASSWORD
}
});
} else {
//QLIK
transporter = nodemailer.createTransport({
host: 'smtp.qliktech.com',
port: 587,
secure: false, // true for 465, false for other ports
});
}
async function _doSend(to, subject, htmlText) {
try {
@@ -49,7 +27,7 @@ async function _doSend(to, subject, htmlText) {
rejectUnauthorized: false
})
});
console.log('SendEmail (BAM)# message id ('+resp.data.info.messageId+') sent to: ' + to);
console.log('SendEmail (BAM)# message sent to: ' + to);
} catch (err) {
// Handle Error Here