This package has been deprecated

Author message:

The current version of email-transporter is no longer supported

email-transporter

1.0.0 • Public • Published

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
            });
        }
    });
});

Readme

Keywords

Package Sidebar

Install

npm i email-transporter

Weekly Downloads

1

Version

1.0.0

License

ISC

Last publish

Collaborators

  • alextanhongpin