@dadi/nodemailer-browser-transport

1.0.1 • Public • Published

Nodemailer Preview Transport

Preview your Nodemailer emails in your browser (Inspired by Letter Opener).

Coverage Status

Usage

  1. Install via NPM

    $ npm install @dadi/nodemailer-browser-transport
    
  2. Use it with Nodemailer

    const nodemailer = require('nodemailer')
    const nodemailerBrowser = require('@dadi/nodemailer-browser-transport')
    
    let tmpdir = require('path').join(process.cwd(), 'tmp', 'nodemailer')
    
    let transport = new nodemailerBrowser({
      dir: tmpdir,
      browser: true
    })
    
    let mailer = nodemailer.createTransport(transport)
    
    mailer.sendMail({
        from: 'hello@domain.com',
        to: user.email,
        // cc:'second@domain.com',
        // bcc:'secretagent@company.gov',
        subject: 'Hello',
        text: 'How are you?'
      }, function (err, info) {
        if (err) {
          console.log('Error: ' + err)
        } else {
          console.log('Response: ' + info)
        }
      })
    }

    Any emails sent through the preview transport will be written to the tmpdir and opened in a browser (unless browser is set to false).

Package Sidebar

Install

npm i @dadi/nodemailer-browser-transport

Weekly Downloads

11

Version

1.0.1

License

BSD

Unpacked Size

13.8 kB

Total Files

7

Last publish

Collaborators

  • annybs
  • josephdenne
  • jimlambie
  • adamkdean