Skip to content

Lightweight (based on Alpine) Docker image for running a (fake) local SMTP server to test outgoing emails (powered by MailCatcher).

License

Notifications You must be signed in to change notification settings

syncloudsoftech/mailcatcher

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

12 Commits
 
 
 
 
 
 
 
 
 
 

Repository files navigation

mailcatcher

Lightweight (based on Alpine) Docker image for running a (fake) local SMTP server to test outgoing emails (powered by MailCatcher).

GitHub Workflow Status Docker Pulls

Usage

To launch a container from this image, you must have Docker installed. If already, run the below command:

$ docker run -d --name mailcatcher -p 1025:1025 -p 8025:8025 syncloudsoftech/mailcatcher

To start/stop the (named) container at a later point in time, use below commnads:

# start "mailcatcher" named container
$ docker start mailcatcher

# stop "mailcatcher" named container
$ docker stop mailcatcher

Once running, you can access the webmail on http://127.0.0.1:8025/ page.

docker-compose.yml

To include this container as a service in your existing docker-compose.yml setup, use below definition:

version: '3'

services:
  mailcatcher:
    image: syncloudsoftech/mailcatcher
    environment:
      HTTP_PORT: '8025' # optional
      SMTP_PORT: '1025' # optional
    ports:
      - '1025:1025'
      - '8025:8025'

Laravel

If your app is built with Laravel, you can configure it to use our docker service by adding below configuration to the .env file.

MAIL_MAILER=smtp
# or use MAIL_HOST=127.0.0.1 if using host network
MAIL_HOST=mailcatcher
MAIL_PORT=1025
MAIL_USERNAME=null
MAIL_PASSWORD=null
MAIL_ENCRYPTION=null
MAIL_FROM_ADDRESS="hello@example.com"
MAIL_FROM_NAME="${APP_NAME}"

Node.js

If your app uses nodemailer, configure it to use our docker service using below code:

const transporter = nodemailer.createTransport({
  host: 'mailcatcher', // or use 127.0.0.1 if using host network
  port: 1025,
  secure: false,
});

Development

Building or modifying the container yourself from source is also quite easy. Just clone the repository and run below command:

$ docker build -t mailcatcher .

Run the locally built container as follows:

$ docker run -it -p 1025:1025 -p 8025:8025 mailcatcher

Testing

Since MailCatcher also includes a REST API for retrieving emails, it's super-easy to use it in testing workflows. See https://mailcatcher.me/#api for documentation.

License

See the LICENSE file.

About

Lightweight (based on Alpine) Docker image for running a (fake) local SMTP server to test outgoing emails (powered by MailCatcher).

Topics

Resources

License

Stars

Watchers

Forks