Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
function initMailer () {
try {
var settings = require('yaml').eval(require('fs').readFileSync(app.root + '/config/mailer.yml').toString('utf8'))[app.settings.env];
} catch (e) {
console.log('Could not init mailer extension, env-specific settings not found in config/mailer.yml');
console.log('Error:', e.message);
return;
}
if (!settings) {
return;
}
exports.settings = settings;
switch (settings.mailer) {
case 'sendmail':
nodemailer.sendmail = true;
break;
case 'smtp':
nodemailer.SMTP = {
host: settings.host || "localhost",
port: settings.port || 25,
use_authentication: settings.use_authentication || false,
user: settings.user || '',
pass: settings.pass || ''
};
break;
}
// read app/views/emails dir
var emailsDir = app.root + '/app/views/emails';
if (path.existsSync(emailsDir)) {
fs.readdirSync(emailsDir).forEach(function (file) {
function ServerChannel (options, server, io) {
this.options = options;
this.server = server;
this.io = io;
this.name = options.name;
if (options.mail) {
nodemailer.sendmail = true;
nodemailer.send_mail({sender: this.name,
to: options.mail.to,
subject: options.mail.subject,
body: "MAIL. For now you cannot change this..."}, // TODO allow for custom body
function(error, success){
console.log("Message "+(success?"sent":"failed"));
});
}
this.nPlayers = options.nPlayers;
this.adminChannel = options.admin;
this.playerChannel = options.player;
this.port = options.port;