Skip to content

dadi/nodemailer-browser-transport

 
 

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

10 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

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).

About

Nodemailer browser preview transport

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages

  • JavaScript 86.3%
  • HTML 13.7%