How to use the emailjs.message function in emailjs

To help you get started, we’ve selected a few emailjs examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github cn007b / my / ed / nodeJs / _ruBookPauersS / pdfToServer / pdf.node.js View on Github external
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="&quot; + url + &quot;">" + url + "</a></p>",
                        alternative: true
                    });
                    server.send(message, function(err, message) {
                        console.log(err || message);
                    });
                    pdftk.kill();
                });
                pdftk.stderr.on('data', function (data) {
github stimulant / ampm / node_modules / winston-mail / lib / winston-mail.js View on Github external
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);
  });
};
github xenophy / NextJS / lib / nx / app / action / Abstract / dollar_mail.js View on Github external
charset: 'iso-2022-jp',
        header: {
            'message-id': '&lt;' + (new Date()).getTime() + '.' + process.pid + '@' + NX.Os.hostname() + '&gt;'
        }
    });

    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) {
github outmoded / postmile / lib / api / email.js View on Github external
internals.sendEmail = function (to, subject, text) {

    var headers = {
        from: (Config.email.fromName || 'Postmaster') + ' &lt;' + (Config.email.replyTo || 'no-reply@localhost') + '&gt;',
        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 });
        }
    });
};
github outmoded / postmile / lib / web / email.js View on Github external
exports.send = function (to, subject, text, html, callback) {

    var headers = {
        from: Config.email.fromName + ' &lt;' + Config.email.replyTo + '&gt;',
        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)));
        }
github hapijs / hapi / lib / email.js View on Github external
exports.send = function (to, subject, text, html, options, callback) {

    var headers = {

        from: (options.fromName || 'Postmaster') + ' &lt;' + (options.replyTo || 'no-reply@localhost') + '&gt;',
        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);
        }
    });
};
github racker / dreadnot / lib / plugins / email.js View on Github external
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', {
github betajs / betajs / src / server / net / smtp.js View on Github external
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);
 		});
	}
github racker / dreadnot / lib / plugins / email.js View on Github external
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
        });
github quocnguyen / uptime / lib / email.js View on Github external
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);
    });
  });

};

emailjs

send text/html emails and attachments (files, streams and strings) from node.js to any smtp server

MIT
Latest version published 1 year ago

Package Health Score

59 / 100
Full package analysis