How to use email-templates - 10 common examples

To help you get started, we’ve selected a few email-templates 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 leafingio / monolithic-node-seed / server / modules / Email / controllers.js View on Github external
exports.Signup = (req, res, next) => {
    if(!req.error){
        var templateDir = path.join(__dirname, 'templates', 'signup')
        var signupTemplate = new EmailTemplate(templateDir)
        var infoTemplate = { 
            user: req.user.email,
            name: req.user.username 
        }

        signupTemplate.render(infoTemplate, function(err, result){
            var emailData = {
                to: req.user.email,
                subject: `Welcome ${req.user.username} to Leafing`,
                text: 'Welcome to Leafing',
                html: result.html
            }
            Email(emailData, (err, info) => {
                /* istanbul ignore if */
                if(err) console.log(err)
                // else console.log(`Signup email sent from ${info.envelope.from} to ${info.envelope.to}`)
github tkssharma / e-CommerseHub / e-Commerce-Admin / app / helper / email.ts View on Github external
welcome(user) {
    if (user.email) {
      let templateDir = path.join('app/global/templates', 'emails', 'welcome-email');
      let welcomeEmail = new EmailTemplate(templateDir);
      welcomeEmail.render({ user: user, activate_url: `${url.API}/auth/activate/${user.uuid}` }, (err, result) => {
        transport.sendMail(
          {
            from: emailConfig.global.from,
            to: user.email,
            subject: emailConfig.welcome.subject,
            html: result.html,
          }, (err, info) => {
            // some error occoured...
            console.log(err);
          }
        );
      });
    }
  },
  password_reset(user, password) {
github tkssharma / e-CommerseHub / e-Commerce-Admin / app / helper / email.ts View on Github external
password_reset(user, password) {
    if (user.email) {
      let templateDir = path.join('app/global/templates', 'emails', 'password-reset-email');
      let passwordResetEmail = new EmailTemplate(templateDir);
      passwordResetEmail.render({ user: user, login_url: `${url.FE}/#/auth/login`, password: password }, (err, result) => {
        transport.sendMail(
          {
            from: emailConfig.global.from,
            to: user.email,
            subject: emailConfig.password_reset.subject,
            html: result.html,
          }, (err, info) => {
            // some error occoured...
          }
        );
      });
    }
    if (user.phone_verified) {
      // Twillo.password_reset_notification(user.phone);
    }
github benjsicam / node-graphql-microservices / grpc-services / mailer / src / services / mailer.service.js View on Github external
async send({ req, response }) {
    let data = Buffer.from(req.data)
    data = JSON.parse(data.toString())
    
    const email = new Email({
      message: {
        from: 'akzdinglasan@gmail.com' // change to support email later
      },
      send: true,
      transport: this._transporter
    })

    this._logger.info(`${this._serviceName}#send.call`, req)

    try {
      const result = await email.send({
        template: path.join(__dirname, '../', 'templates', req.template),
        message: {
          to: req.to
        },
        locals: {
github kartikayg / StatusPage / notification-service / src / lib / email.js View on Github external
const send = async (templateName, subscription, vars, from, transporter) => {

  // email template object. use passed variables or from env conf
  const emailTpl = new EmailTemplate({
    message: {
      from: from || conf.email.SYSTEM_EMAIL_FROM_ADDRESS
    },
    send: true,
    transport: transporter || getDefaultTransporter(),
    views: {
      root: path.resolve('src/email_templates'),
      options: {
        extension: 'ejs'
      }
    }
  });

  // prepare template vars
  const templateVars = Object.assign(_cloneDeep(vars || {}), {
    template: templateName,
github danielwii / asuna-node-server / src / modules / email / email.service.ts View on Github external
secure: configLoader.loadBoolConfig('MAIL_SSL'), // upgrade later with STARTTLS
        auth: {
          user: configLoader.loadConfig('MAIL_USERNAME'),
          pass: configLoader.loadConfig('MAIL_PASSWORD'),
        },
      };
      this.transporter = mailer.createTransport(transport);
    } else {
      logger.warn(oneLine`
        MAIL_HOST && MAIL_PORT && MAIL_USERNAME && MAIL_PASSWORD
        must be set up to send mail in real world
      `);
      this.transporter = mailer.createTransport({ jsonTransport: true });
    }

    this.emailTemplate = new EmailTemplate({
      message: {
        from: configLoader.loadConfig('MAIL_FROM') || configLoader.loadConfig('MAIL_USERNAME'),
      },
      preview: false,
      send: true, // will send emails in development/test env
      subjectPrefix: env === 'production' ? false : `[${env.toUpperCase()}] `,
      transport: this.transporter,
    });
  }
github asafkotzer / apartment-finder / email-sender.js View on Github external
const emailConfig = require('./nconf.js').get('email');
const path = require('path')
const sendgrid = require('sendgrid')(emailConfig.sendgridApiKey);

const EmailTemplate = require('email-templates').EmailTemplate
const templateDir = path.join(__dirname, 'new-ad-email')
const emailTemplate = new EmailTemplate(templateDir)

const Handlebars = require('handlebars');
Handlebars.registerHelper('formatSource', function (source) {
  return source === 'agent' ? 'תיווך' : 'פרטי';
});

const helper = require('sendgrid').mail;
const fromEmail = new helper.Email('ads@apartment-finder.com', 'Apartment Finder');
const replyToEmail = new helper.Email(emailConfig.from);
const personalization = new helper.Personalization();
emailConfig.to.forEach(toEmail => {console.log(toEmail); personalization.addTo(new helper.Email(toEmail))});


const send = (options, callback) => {
    let mail = new helper.Mail();
    mail.setReplyTo(replyToEmail);
github lcortess / simple-parse-smtp-adapter / index.js View on Github external
let renderTemplate = (template, data) => {
        let templateDir = template;
        let html = new EmailTemplate(templateDir);

        return new Promise((resolve, reject) => {
            html.render(data, (err, result) => {
                if (err) {
                    console.log(err)
                    reject(err);
                } else {
                    resolve(result);
                }
            });
        });
    };
github waigo / waigo / src / support / mailer / base.js View on Github external
_renderEmailTemplate (templateName, templateVars) {
    this.logger.debug('Rendering template ' + templateName);

    let templatePath = 
      path.dirname( waigo.getPath(`emails/${templateName}/html.pug`) );

    let emailTemplate = new EmailTemplate(templatePath);

    return new Q((resolve, reject) => {
      emailTemplate.render(templateVars, function(err, result) {
        if (err) {
          reject(err);
        } else {
          resolve(result);
        }
      });
    });
  }
github GetStream / Winds / api / models / Users.js View on Github external
sendRegistrationEmail: function(context, callback) {
            let userEmail = this.email
            let EmailTemplate = require('email-templates').EmailTemplate
            let templateDir = path.join(__dirname, '../../views', 'emails', 'signup')
            let newsletter = new EmailTemplate(templateDir)

            newsletter.render(context, function(err, result) {
                MailerService
                    .send({
                        to: userEmail,
                        subject: result.subject,
                        html: result.html,
                        text: result.text
                    })
                    .then(function(result) {
                        callback(null, result)
                    })
                    .catch(callback)
            })

        },

email-templates

Create, preview (browser/iOS Simulator), and send custom email templates for Node.js. Made for Forward Email and Lad.

MIT
Latest version published 4 months ago

Package Health Score

86 / 100
Full package analysis

Popular email-templates functions