MailDev

SMTP Server + Web Interface for viewing and testing emails during development.

MailDev on Github

MailDev is a simple way to test your projects' emails during development with an easy to use web interface that runs on your machine.

Test responsive emails

Toggle between formats

Find an email quickly

Features

  • Toggle between HTML, plain text views as well as view the source or email headers
  • Test Responsive Emails w/ resizeable preview pane available for 320/480/600px viewports
  • Receive and view email attachments
  • New emails appear instantly in interface when received (via Websockets)
  • Command line interface for configuring SMTP and Web interface ports
  • Ability to relay email to an upstream SMTP server (like Gmail)
  • Export .eml files

Install & Run

npm

With Node.js and npm installed, download, install and run MailDev:

  $ npm install -g maildev
  $ maildev

Docker

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 pull djfarrelly/maildev
  $ docker run -p 1080:80 -p 1025:25 djfarrelly/maildev

From the source

You can also clone the source from GitHub and with Node.js

  $ git clone [email protected]:djfarrelly/MailDev.git
  $ npm install -g ./maildev
  $ maildev

Usage

On the command line:

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 %lt;email<            Use auto-relay mode. Optional relay email address
  --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

Or within your Node.js project:

  const MailDev = require('maildev')

  const maildev = new MailDev()

  maildev.listen()

  // Handle new emails as they come in
  maildev.on('new', (email) => {
    console.log(`Received new email with subject: ${email.subject}`)
  })

  // Get all emails
  maildev.getAllEmail((err, emails) => {
    if (err) return console.log(err)
    console.log(`There are ${emails.length} emails`)
  })

Configure your project

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

Example Setups

  • Node — Nodemailer:
      const transport = nodemailer.createTransport({
        port: 1025,
        ignoreTLS: true,
        // other settings...
      });
    
  • Django — add EMAIL_PORT = 1025 in your settings file [source]
  • Rails — add the port to your config settings:
      config.action_mailer.delivery_method = :smtp
        config.action_mailer.smtp_settings = {
          :address => "localhost",
          :port => 1025
        }
    

For the complete documentation check out the README on Github.

Ideas, Issues or Contributions?

Have an idea or feature request? I would love to here it. File an issue or contact me on twitter @djfarrelly

A list of all releases can be found here on github

Thanks to Andris Reinman for creating his projects that are the backbone of this app and MailCatcher for the inspiration.

MailDev is released under the MIT license