How to use the emailjs/email.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 educatopia / educatopia / api / email-dispatcher.js View on Github external
// ---- module dependencies --------------------- 
var EM = {}
module.exports = EM

// ---- module attributes -----------------------
var mailsettings = {
	host 	 : '',
	user 	 : '',
	password : '',
    sender   : '',
    ssl      : true
}

EM.server = require("emailjs/email").server.connect({
	host 	 : mailsettings.host,
	user 	 : mailsettings.user,
	password : mailsettings.password
    //ssl      : mail.ssl
})

// ---- module exports --------------------------
EM.dispatchRegistrationMail = function(account, callback) {
    var text = "welcome to educatopia\n" +
               "please click the link below!" +
               "http://educatopia.org/verify?user=" + account._id;

	EM.server.send({
		from         : mailsettings.sender,
		to           : account.email,
		subject      : 'educatopia registration',
github developmentseed / jekyll-hook / jekyll-hook.js View on Github external
#!/usr/bin/env node

var config  = require('./config.json');
var fs      = require('fs');
var express = require('express');
var app     = express();
var queue   = require('queue-async');
var tasks   = queue(1);
var spawn   = require('child_process').spawn;
var email   = require('emailjs/email');
var mailer  = email.server.connect(config.email);
var crypto  = require('crypto');

app.use(express.bodyParser({
    verify: function(req,res,buffer){
        if(!req.headers['x-hub-signature']){
            return;
        }

        if(!config.secret || config.secret==""){
            console.log("Recieved a X-Hub-Signature header, but cannot validate as no secret is configured");
            return;
        }

        var hmac         = crypto.createHmac('sha1', config.secret);
        var recieved_sig = req.headers['x-hub-signature'].split('=')[1];
        var computed_sig = hmac.update(buffer).digest('hex');
github gfviegas / express-rest-api / helpers / mailer.js View on Github external
const pug = require('pug')
const emailData = require('../config/template').email
const email = require('emailjs/email')

const server = email.server.connect({
  user: process.env.MAIL_USER,
  password: process.env.MAIL_PASSWORD,
  host: process.env.MAIL_HOST,
  port: process.env.MAIL_PORT,
  ssl: true
})

const sendMail = (options) => {
  return new Promise((resolve, reject) => {
    const data = Object.assign({_email: emailData}, options.template.data)
    const mailPath = `${process.cwd()}/templates/mails/${options.template.path}.pug`
    const htmlstream = pug.renderFile(mailPath, data)
    const message = {
      from: `${process.env.MAIL_ACCOUNT_NAME} <${process.env.MAIL_HOST}>`,
      to: (process.env.NODE_ENV === 'development' || process.env.NODE_ENV === 'test') ? process.env.MAIL_DEV_FALLBACK : (options.to),
      subject: options.subject,
github konforti / people / util / sendmail / index1.js View on Github external
var attachments = [];

      if (options.html) {
        attachments.push({ data: options.html, alternative: true });
      }

      if (options.attachments) {
        for (var i = 0 ; i < options.attachments.length ; i++) {
          attachments.push(options.attachments[i]);
        }
      }

      var emailjs = require('emailjs/email');
      var settings = app.getSettings();
      var emailer = emailjs.server.connect( {
        user: settings.smtpUser,
        password: settings.smtpPassword,
        host: settings.smtpHost,
        ssl: settings.smtpSSL
      } );
      emailer.send({
        from: options.from,
        to: options.to,
        'reply-to': options.replyTo || options.from,
        cc: options.cc,
        bcc: options.bcc,
        subject: options.subject,
        text: options.text,
        attachment: attachments
      }, function(err, message) {
        if (err) {
github gadael / gadael / modules / sendmail.js View on Github external
var attachements = [];

  if (options.html) {
	attachements.push({ data: options.html, alternative: true });
  }

  if (options.attachments) {
	for (var i = 0 ; i < options.attachments.length ; i++) {
	  attachements.push(options.attachments[i]);
	}
  }

  var emailjs = require('emailjs/email');
  var emailer = emailjs.server.connect( req.app.config.smtp.credentials );
  emailer.send({
	from: options.from,
	to: options.to,
	'reply-to': options.replyTo || options.from,
	cc: options.cc,
	bcc: options.bcc,
	subject: options.subject,
	text: options.text,
	attachment: attachements
  }, function(err, message) {
	if (err) {
	  options.error('Email failed to send. '+ err);
	  return;
	}
	else {
	  options.success(message);
github HubYard / HubYard / data.js View on Github external
saltAndHash(pass, function(hash){
                        o.pass = hash;
                        accounts.save(o, {safe: true}, function(err) {	
                            if(err){
                                res.send(400);
                            } else {
                                res.send(200)
                            }
                        });	
                    });
                }
            });
        }
	});
    
    var server = require("emailjs/email").server.connect({

        host 	    : keys.email.host,
        user 	    : keys.email.user,
        password    : keys.email.password,
        ssl		    : true

    });

    var dispatchResetPasswordLink = function(account, callback)
    {
        server.send({
            from         : keys.email.sender,
            to           : account.email,
            subject      : 'Password Reset',
            text         : 'something went wrong... :(',
            attachment   : composeEmail(account)
github SlashmanX / xForum / server / modules / email-dispatcher.js View on Github external
var ES = require('./email-settings');
var UEV = require('../models/UserEmailVerification.js');
var	mongoose	=	require('mongoose');
var	moment		=	require('moment');
var	ObjectId	=	mongoose.Types.ObjectId;
var EM = {};
module.exports = EM;

EM.server = require("emailjs/email").server.connect({

   	host 	    : ES.host,
   	user 	    : ES.user,
   	password    : ES.password,
    ssl		    : true

});

EM.send = function(credentials, callback)
{
    EM.drawVerificationEmail(credentials, function(att){
        EM.server.send({
            from         : ES.sender,
            to           : credentials.email,
            subject      : '[xForum] Verify your email',
            text         : 'something went wrong... :(',
github braitsch / node-login / app / server / modules / email-dispatcher.js View on Github external
var EM = {};
module.exports = EM;

EM.server = require("emailjs/email").server.connect(
{
	host 	    : process.env.NL_EMAIL_HOST || 'smtp.gmail.com',
	user 	    : process.env.NL_EMAIL_USER || 'your-email-address@gmail.com',
	password    : process.env.NL_EMAIL_PASS || '1234',
	ssl		    : true
});

EM.dispatchResetPasswordLink = function(account, callback)
{
	EM.server.send({
		from         : process.env.NL_EMAIL_FROM || 'Node Login ',
		to           : account.email,
		subject      : 'Password Reset',
		text         : 'something went wrong... :(',
		attachment   : EM.composeEmail(account)
	}, callback );
github futurestudio / nodejs-account-boilerplate / server / modules / email-dispatcher.js View on Github external
var ES = require('../settings/email');
var EM = {};
module.exports = EM;

EM.server = require("emailjs/email").server.connect({
    host        : ES.host,
    user        : ES.user,
    password    : ES.password,
    ssl         : true

});

EM.dispatchWelcomeEmail = function(account, callback)
{
    if (ES.sendWelcomeEmail)
    {
        EM.server.send({
            from : ES.sender,
            to : account.email,
            subject : 'Welcome to nodejs-account-boilerplate',
            text : 'something went wrong... :(',
github jedireza / drywall / util / sendmail / index.js View on Github external
}

      var attachments = [];

      if (options.html) {
        attachments.push({ data: options.html, alternative: true });
      }

      if (options.attachments) {
        for (var i = 0 ; i < options.attachments.length ; i++) {
          attachments.push(options.attachments[i]);
        }
      }

      var emailjs = require('emailjs/email');
      var emailer = emailjs.server.connect( req.app.config.smtp.credentials );
      emailer.send({
        from: options.from,
        to: options.to,
        'reply-to': options.replyTo || options.from,
        cc: options.cc,
        bcc: options.bcc,
        subject: options.subject,
        text: options.text,
        attachment: attachments
      }, function(err, message) {
        if (err) {
          options.error('Email failed to send. '+ err);
          return;
        }
        else {
          options.success(message);

emailjs

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

MIT
Latest version published 9 months ago

Package Health Score

66 / 100
Full package analysis