New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More
Socket
Sign inDemoInstall
Socket

punch-emailer

Package Overview
Dependencies
Maintainers
1
Versions
1
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

punch-emailer

Module for send emails based on nodemailer.

  • 0.0.1
  • latest
  • npm
  • Socket score

Version published
Maintainers
1
Created
Source

punch-emailer

Send emails

Config

  • from - email address that used to send emails
  • templateDir - dir with email templates
  • nodemailerConf - nodeemail config see https://github.com/nodemailer/nodemailer
  • logger - function that can log sent emails (example - console.log)

Templates

see email-templates documentation https://github.com/niftylettuce/node-email-templates

<div>
  Hello, <%= user.firstName + ' ' + user.lastName %>
  Reset password link <a href="<%- verificationLink %>" target="_blank">link</a>
  Or just copy the link: <%- verificationLink %>
</div>

Usage

'use strict';
const PunchEmailer = require('punch-emailer');
const path = require('path');


const smtpConfig = {
  host:  process.env.SMTP_HOST || 'xxxxx',
  port:  process.env.SMTP_PORT || 465,
  secure:  process.env.SMTP_SECURE || true, // use SSL
  auth: {
    user:  process.env.SMTP_USER || 'xxxxx',
    pass:  process.env.SMTP_PASS || 'xxxxx'
  }
};

const HOST = process.env.HOST || ' http://xxxxx.com/';
const querystring = require("querystring");
const templateDir = path.join(__dirname, 'templates');

const config = {
  from:  process.env.SMTP_FROM || 'no-reply@xxxxx.com',
  templateDir: templateDir,
  nodemailerConf : smtpConfig
};



class Emailer extends PunchEmailer {
  sendEmailVerification(to, data){
    let queryParams = querystring.stringify({email : to, code : data.verificationCode});
    data.verificationLink =  HOST + '#/confirm-email?' + queryParams;
    return this.sendTemplate(
      to,
      'Email verification',
      'email-verification',
      data
    );
  };

  sendResetPassword(to, data){
    let queryParams = querystring.stringify({email : to, code : data.verificationCode});
    data.verificationLink =  HOST + '#/reset-password?' + queryParams;
    return this.sendTemplate(
      to,
      'Reset password',
      'reset-password',
      data
    );
  };
};

module.exports = new Emailer(config);

const emailer = require('./emailer');

emailer.sendEmailVerification('test@te.st', {
    user : {
      firstName : 'Jastin',
      lastName : 'Hastin'
    },
    verificationCode : 'xxx-xxx-xxxx'
    })

FAQs

Package last updated on 20 Jul 2016

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc