Local Mail Server During Development

Snippet

Sometimes, you need to send email during software development, and you need to be able to receive the email, even if the addresses are fake (say, to @example.org) and what have you.

The node package, fake-smtp-server is a handy tool for providing a server to receive the mail, and an interface for viewing the email that was sent.

https://www.npmjs.com/package/fake-smtp-server

Install globally on a system with:

npm install -g fake-smtp-server

Start it up:

fake-smtp-server

If you want to have it on port 25 as most mail servers expect, run as root:

sudo fake-smtp-server -s 25

View the emails received (by default) at

http://localhost:1080

You can change that port, too:

sudo fake-smtp-server -h 8888

A few other configurations, and an API. Great little tool.

Usage:
  fake-smtp-server [OPTIONS] [ARGS]
 
Options:
  -s, --smtp-port [NUMBER] SMTP port to listen on (Default is 1025)
      --smtp-ip [IP]       IP Address to bind SMTP service to (Default is 0.0.0.0)
  -h, --http-port [NUMBER] HTTP port to listen on (Default is 1080)
      --http-ip [IP]       IP Address to bind HTTP service to (Default is 0.0.0.0)
  -w, --whitelist STRING   Only accept e-mails from these adresses. Accepts
                           multiple e-mails comma-separated
  -m, --max [NUMBER]       Max number of e-mails to keep (Default is 100)
  -a, --auth STRING        Enable Authentication
      --headers            Enable headers in responses
  -k, --no-color           Omit color from output
      --debug              Show debug information

Add new comment

Plain text

  • No HTML tags allowed.
  • Lines and paragraphs break automatically.