Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
console.log('sending email');
// отправка сообщения по электронной почте
var server = emailjs.server.connect({
user : 'gmail.account.name',
password : 'gmail.account.passwod',
host : 'smtp.gmail.com',
port : 587,
tls : true
});
var headers = {
text : 'You can find your split PDF at ' + url,
from : 'youremail',
to : email,
subject: 'split pdf'
};
var message = emailjs.message.create(headers);
message.attach({
data:"<p>You can find your split PDF at " + "<a href="" + url + "">" + url + "</a></p>",
alternative: true
});
server.send(message, function(err, message) {
console.log(err || message);
});
pdftk.kill();
});
pdftk.stderr.on('data', function (data) {
if (meta !== null && meta !== undefined && (typeof meta !== 'object' || Object.keys(meta).length > 0))
body += "\n\n" + util.inspect(meta, {depth: 5}); // add some pretty printing
var msgOptions = {
from: this.from,
to: this.to,
subject: this.subject({level: level, msg: msg.split('\n')[0]}),
text: body
};
//Send mail as html
if (this.html){
msgOptions.attachment = [{data: body , alternative:true}];
}
var message = email.message.create(msgOptions);
this.server.send(message, function (err) {
if (err) self.emit('error', err);
self.emit('logged');
callback(null, true);
});
};
charset: 'iso-2022-jp',
header: {
'message-id': '<' + (new Date()).getTime() + '.' + process.pid + '@' + NX.Os.hostname() + '>'
}
});
NX.applyIf(config, {
content: 'text/plain; charset=' + config.charset.toLowerCase()
});
var iconv = new Iconv('UTF-8', config.charset);
var buffer = iconv.convert(config.subject || '');
config.subject = buffer.toString();
var message = email.message.create(config);
// 添付ファイル処理
if(config.files) {
if(NX.isObject(config.files)) {
config.files = [config.files];
}
if(NX.isArray(config.files)) {
config.files.forEach(function(item) {
var name = item.name;
var ext = name.substr(name.indexOf('.') + 1);
if(!item.type) {
internals.sendEmail = function (to, subject, text) {
var headers = {
from: (Config.email.fromName || 'Postmaster') + ' <' + (Config.email.replyTo || 'no-reply@localhost') + '>',
to: to,
subject: subject,
text: text
};
var message = Email.message.create(headers);
var mailer = Email.server.connect(Config.email.server || {});
mailer.send(message, function (err, message) {
if (err) {
console.log('Email error', { to: to, subject: subject, text: text, error: err });
}
});
};
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)));
}
exports.send = function (to, subject, text, html, options, callback) {
var headers = {
from: (options.fromName || 'Postmaster') + ' <' + (options.replyTo || 'no-reply@localhost') + '>',
to: to,
subject: subject,
text: text
};
var message = Email.message.create(headers);
if (html) {
message.attach_alternative(html);
}
var mailer = Email.server.connect(options.server || {});
mailer.send(message, function (err, message) {
if (callback) {
callback(err ? Err.internal('Failed sending email: ' + JSON.stringify(err)) : null);
}
});
};
dreadnot.emitter.once(endPath, function(success) {
var endMessage = email.message.create({
to: config.to,
from: config.from,
subject: sprintf(END_SUBJ_FMT, deployment.deployment, deployment.stack, dreadnot.config.env, deployment.region,
success ? 'SUCCESS': 'FAILURE'),
text: sprintf(END_TEXT_FMT.join('\n'),
deployment.user,
new Date(deployment.time).toUTCString(),
helpers.trimRevision(deployment.from_revision), helpers.trimRevision(deployment.to_revision),
helpers.ghDiffUrl(deployment.github_href, deployment.from_revision, deployment.to_revision),
logEvents.map(function(logEvent) {
return logEvent.msg;
}).join('\n'))
});
server.send(endMessage, function(err) {
log.error('error sending deployment end email', {
send: function (config, message, callbacks) {
var email = require("emailjs");
message.from = BetaJS.Strings.email_get_email(message.from);
message.to = BetaJS.Strings.email_get_email(message.to);
if (message.text_body) {
message.text = message.text_body;
delete message.text_body;
}
email.server.connect(config).send(email.message.create(message), function (err, msg) {
if (err)
BetaJS.SyncAsync.callback(callbacks, "exception", err);
else
BetaJS.SyncAsync.callback(callbacks, "success", msg);
});
}
dreadnot.emitter.on('deployments', function(deployment) {
var endPath = ['stacks', deployment.stack, 'regions', deployment.region, 'deployments', deployment.deployment, 'end'].join('.'),
logPath = ['stacks', deployment.stack, 'regions', deployment.region, 'deployments', deployment.deployment, 'log'].join('.'),
logEvents = [],
server, message;
server = email.server.connect(config.server);
message = email.message.create({
to: config.to,
from: config.from,
subject: sprintf(BEG_SUBJ_FMT, deployment.deployment, deployment.stack, dreadnot.config.env, deployment.region),
text: sprintf(BEG_TEXT_FMT.join('\n'),
deployment.user,
new Date(deployment.time).toUTCString(),
helpers.trimRevision(deployment.from_revision), helpers.trimRevision(deployment.to_revision),
helpers.ghDiffUrl(deployment.github_href, deployment.from_revision, deployment.to_revision))
});
server.send(message, function(err) {
if (err) {
log.error('error sending deployment email', {
deployment: deployment,
err: err
});
exports.send = function send(msg) {
if ( process.env.NODE_ENV !== 'production') {
return Promise.resolve();
}
msg = xtend(msg, {
from: process.env.ADMIN_EMAIL,
attachment: [{
data: msg.text || '',
alternative: true
}]
});
var message = emailjs.message.create(msg);
return new Promise((resolve, reject) => {
server.send(message, function(err, res){
if (err) { return reject(err); }
resolve(res);
});
});
};