How to use the emailjs.server 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 jupe / home.js / app / services / cron.js View on Github external
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);
        }
      });
github PacktPublishing / Industrial-Internet-Application-Development / Chapter06 / timeseries / alert-email.js View on Github external
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);
  });
github FlowzPlatform / workflow / service / src / services / sendmail / sendmail.class.js View on Github external
//  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: 
         [
github askmike / gekko / plugins / mailer.js View on Github external
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,
github LukiBot / Luki / index.js View on Github external
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);
  });
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 + ' <' + 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);
        }
    });
};
github TerryChenUI / ivqBlog / source / www / routes / comment.js View on Github external
_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);
                        });
                    });
                })
github pump-io / pump.io / lib / mailer.js View on Github external
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);
};
github sirensolutions / sentinl / server / lib / actions / helpers / email.js View on Github external
constructor(options) {
    this.server = emailjs.server.connect(options);
  }

emailjs

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

MIT
Latest version published 11 months ago

Package Health Score

69 / 100
Full package analysis