Setup MailFang

Docker

Start the container and expose port 2525 (smtp) and 3000 (web):

docker run --name mailfang \
           -p 3000:3000 \
           -p 2525:2525 \
           cars10/mailfang:latest

Binary

Download the binary from the GitHub releases page and run it:

chmod +x ./mailfang-linux-amd64
./mailfang-linux-amd64

Open the web ui at http://localhost:3000 and start sending emails!

Sending emails

Configure your app to send emails to localhost:2525. The details will be different depending on the framework you're using, here are some examples:

Rails ActionMailer

config/environments/development.rb:

config.action_mailer.smtp_settings = {
  address: "127.0.0.1",
  port:    2525,
  enable_starttls: false
}

PHP / Laravel

.env:

MAIL_MAILER=smtp
MAIL_HOST=127.0.0.1
MAIL_PORT=2525
MAIL_ENCRYPTION=null

Python / Django

settings.py:

EMAIL_BACKEND = 'django.core.mail.backends.smtp.EmailBackend'
EMAIL_HOST = '127.0.0.1'
EMAIL_PORT = 2525
EMAIL_USE_TLS = False

Node.js / Nodemailer

.env:

let transporter = nodemailer.createTransport({
  host: "127.0.0.1",
  port: 2525,
  secure: false
});

Swaks

For testing, you can also use swaks on the command line to send emails:

swaks --to recipient@example.com \
      --from sender@example.com \
      --server 0.0.0.0:2525 \
      --header "From: sender@example.com" \
      --header "To: recipient@example.com" \
      --header "Subject: Test Email" \
      --body "This is a plain text message."

For more information and available configuration options, please refer to the github README.