Skip to content

Phenelo/respondence

Repository files navigation

respondence

Build Status Coverage Status Code Climate NPM Version Dependency Status
Known Vulnerabilities

A simple hapijs plugin for sending e-mails. Uses nodemailer.

Usage

const Respondence = require('respondence');
const server = new Hapi.Server();

await server.register({
    plugin: Respondence,
    options: {
        smtp: 'smtps://user%40gmail.com:[email protected]'
    }
});

Sending email

const mail = {
     from: '"Baroof" <[email protected]>',
     to: '[email protected]',
     subject: 'Foo',
     text: 'A bar without foo is barfoo.'
},

try {
    
    await server.plugins.respondence.send(internals.mail);
}
catch(err) {
    
    console.log(err);
}

Verifying SMTP connection

try {
    
    await server.plugins.respondence.verify();
}
catch(err) {
    
    console.log(err);
}

Registering with a transport plugin

const Mailgun = require('nodemailer-mailgun-transport');

await server.register({
    register: Respondence,
    options: {
        plugin: Mailgun,
        params: {
            auth: {
                api_key: 'api-key1234567890',
                domain: '1234567890.mailgun.org'
            }
        }
    }
});

See more transport plugins here and nodemailer for more information.

Contributing

About

A simple hapijs plugin for sending e-mails.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published