Socket
Socket
Sign inDemoInstall

email-transporter

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

email-transporter

a simple pluggable email container for nodemailer


Version published
Weekly downloads
2
Maintainers
1
Weekly downloads
 
Created
Source

Email Transporter

A simple email transporter that utilizes nodemailer and email-template module.

// email-factory.js
const path = require('path');
const nodemail = require('email-transporter')({
    agent: require('nodemailer'),
    config: require('../config/main.js').smtp,
    template: require('email-templates').EmailTemplate
});

const EmailTemplate = require('email-templates').EmailTemplate;

function sendInvitationEmail(options, body) {
    const templateDir = path.join(__dirname, '..', 'template', 'invite')
    return nodemail.template({
        dir: templateDir,
        // The data that will be populated in the template
        data: {
            name: body.name,
            surname: body.surname,
            id: body.id,
        },
        from: options.from,
        to: options.to, 
        subject: options.subject,
    });
}


module.exports = {
    send: sendInvitationEmail
}
// server.js
app.get('/invite', (req, res) => {
    const to = 'alexander.hongpin@gmail.com';
    emailClient.send({
        from: '"Fred Foo 👥" <foo@blurdybloop.com>',
        to: to,
        subject: 'Join us now!',
    }, {
        name: 'john',
        surname: 'doe',
        id: 'X07569'
    }).then((response) => {
        if (response) {
            res.status(200).json({
                data: 'successfull sent the email to ' + to
            });
        }
    });
});

Keywords

FAQs

Package last updated on 01 Nov 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