Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
function sendEmail( to, subject, msg, cb){
var cfg = CFG.email;
var server = email.server.connect( cfg );
server.send( {
text: msg, from: cfg.from, to: to, subject: subject
}, function (err, message) {
if (err) {
// handle error
console.log('There was an error sending the email');
console.log(err);
event('error', 'sendEmail failed', err);
if(cb)cb(err);
}else {
console.log('Email sended');
console.log(message);
event('info', 'sendEmail', message);
if(cb)cb(null, message);
}
});
var email = require('emailjs');
var server = email.server.connect({
user: 'username@gmail.com',
password: 'password',
host: 'smtp.gmail.com',
ssl: true
});
// send the message and get a callback with an error or details of the message that was sent
function alertEmail(msg) {
server.send({
text: msg,
from: 'username@gmail.com',
to: 'username@gmail.com',
subject: 'Alert'
}, function (err, message) {
console.log(err || message);
});
// console.log(params)
let smtpUser = user
let smtpPassword = password
let smtpHost = host
if (params.headers.smtp_user) {
smtpUser = params.headers.smtp_user
}
if (params.headers.smtp_password) {
smtpPassword = params.headers.smtp_password
}
if (params.headers.smtp_host) {
smtpHost = params.headers.smtp_host
}
// console.log('', smtpHost, smtpPassword, smtpUser)
if (smtpHost !== '' && smtpHost !== undefined && smtpPassword !== '' && smtpPassword !== undefined && smtpHost !== '' && smtpHost !== undefined) {
let SMTPServer = email.server.connect({
user: smtpUser,
password: smtpPassword,
host: smtpHost,
ssl: false
});
return new Promise((resolve, reject) => {
SMTPServer.send({
text: data['body'],
// html: 'Nikita',
from: data['from'],
to: data['to'],
cc: data['cc'],
bcc: data['bcc'],
subject: data['subject'],
attachment:
[
var setupMail = function(err, result) {
if(result) {
console.log('Got it.');
mailConfig.password = result.password;
}
if(_.isEmpty(mailConfig.to))
mailConfig.to = mailConfig.email;
if(_.isEmpty(mailConfig.from))
mailConfig.from = mailConfig.email;
if(_.isEmpty(mailConfig.user) && mailConfig.smtpauth)
mailConfig.user = mailConfig.email;
this.server = email.server.connect({
user: mailConfig.user,
password: mailConfig.password,
host: mailConfig.server,
ssl: mailConfig.ssl,
port: mailConfig.port,
tls: mailConfig.tls
});
if(mailConfig.sendMailOnStart) {
this.mail(
"Gekko has started",
[
"I've just started watching ",
config.watch.exchange,
' ',
config.watch.currency,
if (!guild.me) await guild.members.fetch(this.client.user.id).catch(() => null);
player.connect({
session: guild.me.voiceSessionID,
event: data
});
}
}
client.on('ready', () => {
client.playerManager = new Player(client, client.lavaLinkNodes, {
user: client.user.id
});
});
client.mailer = email.server.connect({
user: client.config.mailer.address,
password: client.config.mailer.password,
host: client.config.mailer.host,
ssl: client.config.mailer.ssl
});
const init = async () => {
const cmdFiles = await readdir("./commands/");
client.logger.log(`Loading a total of ${cmdFiles.length} commands.`);
cmdFiles.forEach(f => {
if (!f.endsWith(".js")) return;
const response = client.loadCommand(f);
if (response) console.log(response);
});
exports.send = function (to, subject, text, html, callback) {
var headers = {
from: Config.email.fromName + ' <' + Config.email.replyTo + '>',
to: to,
subject: subject,
text: text
};
var message = Email.message.create(headers);
if (html) {
message.attach_alternative(html);
}
var mailer = Email.server.connect(Config.email.server);
mailer.send(message, function (err, message) {
if (err) {
if (!callback) {
return console.log('Email error: ' + JSON.stringify(err));
}
return callback(Hapi.error.internal('Failed sending email: ' + JSON.stringify(err)));
}
if (callback) {
return callback(null);
}
});
};
_und.each(settings, function (setting) {
emailSetting[setting.key] = setting.value;
});
if (!emailSetting['setting.email.enabled'])
return res.sendStatus(200);
var message = {
text: newComment.content,
from: "ivqBlog ",
to: newComment.userName + " <" + newComment.email + ">",
subject: "ivqBlog 回复"
};
var server = email.server.connect({
user: emailSetting['setting.email.user'],
password: emailSetting['setting.email.password'],
host: emailSetting['setting.email.host'],
ssl: emailSetting['setting.email.ssl']
});
server.send(message, function (err, message) {
console.log(err || message);
return res.sendStatus(200);
});
});
})
password: config.smtppass,
host: config.smtpserver,
port: config.smtpport,
ssl: config.smtpusessl,
tls: config.smtpusetls,
timeout: config.smtptimeout,
domain: hostname
};
maillog = log.child({component: "mail"});
from = config.smtpfrom;
maillog.debug(_.omit(mailopts, "password"), "Connecting to SMTP server");
smtp = email.server.connect(mailopts);
};
constructor(options) {
this.server = emailjs.server.connect(options);
}