A stream interface for sending emails that works with bunyan logger.

Usage no npm install needed!

<script type="module">
  import bsEmail from '';


Bunyan Stream Email


A stream interface that sends email with each write through common nodemailer transporters and is meant to be used with the NodeJS logger bunyan.

Currently, the log record will simply be emailed as pretty-printed JSON text; however, in the future, the log messages will be formatted.


'use strict';
const BunyanStreamEmail = require('bs-email');
const nodemailer = require('nodemailer');
const bunyan = require('bunyan');
const sendmailTransport = require('nodemailer-sendmail-transport');

// Create transporter (could be any number of the nodemailer transporters)
const transporter = nodemailer.createTransport(sendmailTransport());

// Create a stream
const emailStream = new BunyanStreamEmail(
    sender: '',
    recipient: ''

// Create the logger and register the stream
const log = bunyan.createLogger({
  name: 'ExampleAppLogger',
  streams: [
      stream: emailStream,
      type: 'raw',
      level: 'fatal'

// Trigger some logs! Our email stream will be written to for log events meeting
// the set level filter
log.fatal('I\'m a fatal log message.');
log.fatal('Did you get my last email?');