Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

maildev

Package Overview
Dependencies
Maintainers
1
Versions
46
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

maildev

SMTP Server and Web Interface for reading and testing emails during development

  • 1.0.0-beta2
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
89K
increased by14.67%
Maintainers
1
Weekly downloads
 
Created
Source

MailDev

Build Status codecov NPM Version JavaScript Style Guide

MailDev is a simple way to test your project's generated emails during development with an easy to use web interface that runs on your machine built on top of Node.js.

MailDev Screenshot

Install & Run

$ npm install -g maildev
$ maildev

If you want to use MailDev with Docker, you can use the djfarrelly/maildev image on Docker Hub. For a guide for usage with Docker, checkout the docs.

$ docker run -p 1080:80 -p 1025:25 djfarrelly/maildev

For convenient use with Grunt, try grunt-maildev.

Usage

maildev [options]

  -h, --help                      output usage information
  -V, --version                   output the version number
  -s, --smtp <port>               SMTP port to catch emails [1025]
  -w, --web <port>                Port to run the Web GUI [1080]
  --ip <ip address>               IP Address to bind SMTP service to
  --outgoing-host <host>          SMTP host for outgoing emails
  --outgoing-port <port>          SMTP port for outgoing emails
  --outgoing-user <user>          SMTP user for outgoing emails
  --outgoing-pass <password>      SMTP password for outgoing emails
  --outgoing-secure               Use SMTP SSL for outgoing emails
  --auto-relay                    Use auto-relay mode
  --auto-relay-rules <file>       Filter rules for auto relay mode
  --incoming-user <user>          SMTP user for incoming emails
  --incoming-pass <pass>          SMTP password for incoming emails
  --web-ip <ip address>           IP Address to bind HTTP service to, defaults to --ip
  --web-user <user>               HTTP user for GUI
  --web-pass <password>           HTTP password for GUI
  --base-pathname <path>          base path for URLs
  --disable-web                   Disable the use of the web interface. Useful for unit testing
  --hide-extensions <extensions>  Comma separated list of SMTP extensions to NOT advertise
                                  (STARTTLS, SMTPUTF8, PIPELINING, 8BITMIME)
  -o, --open                      Open the Web GUI after startup
  -v, --verbose
  --silent

API

MailDev can be used in your Node.js application. For more info view the API docs.

const MailDev = require('maildev')

const maildev = new MailDev()

maildev.listen()

maildev.on('new', function (email) {
  // We got a new email!
})

MailDev also has a REST API. For more info view the docs.

Outgoing email

Maildev optionally supports selectively relaying email to an outgoing SMTP server. If you configure outgoing email with the --outgoing-* options you can click "Relay" on an individual email to relay through MailDev out to a real SMTP service that will actually send the email to the recipient.

Example:

$ maildev --outgoing-host smtp.gmail.com \
          --outgoing-secure \
          --outgoing-user 'you@gmail.com' \
          --outgoing-pass '<pass>'

Auto relay mode

Enabling the auto relay mode will automatically send each email to it's recipient without the need to click the "Relay" button mentioned above. The outgoing email options are required to enable this feature.

Additionally, you can pass a valid json file with additional configuration for what email addresses you would like to allow or deny. The last matching rule in the array will be the rule MailDev will follow.

Example:

$ maildev --outgoing-host smtp.gmail.com \
          --outgoing-secure \
          --outgoing-user 'you@gmail.com' \
          --outgoing-pass '<pass>' \
          --auto-relay \
          --auto-relay-rules file.json

Rules example file:

[
	{ "allow": "*" },
	{ "deny":  "*@test.com" },
	{ "allow": "ok@test.com" },
	{ "deny":  "*@utah.com" },
	{ "allow": "johnny@utah.com" }
]

This would allow angelo@fbi.gov, ok@test.com, johnny@utah.com, but deny bodhi@test.com.

Configure your project

Configure your application to send emails via port 1025 and open localhost:1080 in your browser.

Nodemailer (v1.0+)

const transport = nodemailer.createTransport({
  port: 1025,
  ignoreTLS: true,
  // other settings...
})

Nodemailer (v0.7)

const transport = nodemailer.createTransport('SMTP', {
  port: 1025,
  // other settings...
})

Django -- Add EMAIL_PORT = 1025 in your settings file [source]

Rails -- config settings:

config.action_mailer.delivery_method = :smtp
    config.action_mailer.smtp_settings = {
        :address => "localhost",
        :port => 1025
    }

Drupal -- Install and configure SMTP module or use a library like SwiftMailer.

Features

  • Toggle between HTML, plain text views as well as view email headers
  • Test Responsive Emails w/ resizeable preview pane available for 320/480/600px screen sizes
  • Ability to receive and view email attachments
  • Websockets keep the interface in sync once emails are received
  • Command line interface for configuring SMTP and Web interface ports
  • Ability to relay email to an upstream SMTP server

Ideas

If you're using MailDev and you have a great idea, I'd love to hear it. If you're not using MailDev because it lacks a feature, I'd love to hear that too. Add an issue to the repo here or contact me on twitter.

Contributing

Any help on MailDev would be awesome. There is plenty of room for improvement. Feel free to create a Pull Request from small to big changes.

To run MailDev during development:

npm install
npm run dev

The "dev" task will run MailDev using nodemon and restart automatically when changes are detected. On *.scss file save, the css will also be recompiled. Using test/send.js, a few test emails will be sent every time the application restarts.

The project uses the JavaScript Standard coding style. To lint your code before submitting your PR, run npm run lint.

To run the test suite:

$ npm test

Changelog

Thanks

MailDev is built on using great open source projects including Express, AngularJS, Font Awesome and two great projects from Andris Reinman: smtp-server and mailparser. Many thanks to Andris as his projects are the backbone of this app and to MailCatcher for the inspiration.

Additionally, thanks to all the awesome contributors to the project.

License

MIT

Keywords

FAQs

Package last updated on 11 May 2017

Did you know?

Socket

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
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc