Socket
Socket
Sign inDemoInstall

nodemailer-stub-transport

Package Overview
Dependencies
0
Maintainers
1
Versions
7
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

    nodemailer-stub-transport

Stub transport for Nodemailer


Version published
Maintainers
1
Install size
9.58 kB
Created

Readme

Source

Stub transport module for Nodemailer

Applies for Nodemailer v1.0

Stub transport does not send anything, it builds the mail stream into a single Buffer and returns it with the sendMail callback. This is useful for testing the emails before actually sending anything.

Build Status NPM version

Usage

Install with npm

npm install nodemailer-stub-transport

Require to your script

var nodemailer = require('nodemailer');
var stubTransport = require('nodemailer-stub-transport');

Create a Nodemailer transport object

var transport = nodemailer.createTransport(stubTransport());

Send a message

transport.sendMail(mailData, function(err, info){
    console.log(info.response.toString());
});

or "verify" settings

transport.verify(function(err, success){
    if (error) {
        console.log(error);
   } else {
        console.log('Server is ready to take our messages');
   }
});

Errors

There's not much to error about but if you want the sending to fail and return an error then you can do this by specifying an error option when setting up the transport .

var transport = nodemailer.createTransport(stubTransport({
    error: new Error('Invalid recipient')
}));
transport.sendMail(mailData, function(err, info){
    console.log(err.message); // 'Invalid recipient'
});

Setting an error also applies to the verify call

transport.verify(function(err, success){
    console.log(err.message); // 'Invalid recipient'
});

Using BCC

If you want to have BCC addresses included in the generated message, use keepBcc option

var transport = nodemailer.createTransport(stubTransport({
    keepBcc: true
}));

Events

'log'

Debug log object with {name, version, level, type, message}

'envelope'

Envelope object

'data'

Data chunk

License

MIT

Keywords

FAQs

Last updated on 18 Aug 2016

Did you know?

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

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc