Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
this.send_email = function(host, email_data, callback){
this.log('Trying to send to ' + email_data.to + ' at ' + host);
var transport_opts = {host: host, secureConnection: false}; // SSL bug?
var transport = mailer.createTransport("SMTP", transport_opts);
email_data.transport = transport;
mailer.sendMail(email_data, function(err){
transport.close();
callback(err);
});
};
var sendSubscriptionEmail = function(emails) {
var email = emails.shift();
if (email) {
nodemailer.sendMail(email, function(err){
if (err){
console.log(err);
} else{
console.log("Sent email to " + email.to);
sendSubscriptionEmail(emails);
}
});
} else {
console.log("Finished sending emails");
mailTransport.close();
}
};
auth: {
user: this.baseConfig.email.username,
pass: this.baseConfig.email.password
}
});
var mailOptions = {
transport: transport,
from: "Site Alert <" + this.baseConfig.email.sender + ">",
to: this.config.address,
subject: up_down == 'down' ? site.name + ' is down!' : site.name + ' is up!',
text: body,
html: htmlBody
}
nodemailer.sendMail(mailOptions, function(error){
if(error){
callback(false, error);
}else{
callback(true);
}
});
}