MailDev - Mail Server on Your Local Environment

MailDev - Mail Server on Your Local Environment

Takahiro Iwasa
Takahiro Iwasa
1 min read

When developing an application, MailDev is useful to send and receive emails within user’s local environment.

Launching MailDev

Create Dockerfile using the example below.

FROM node:14-alpine
RUN npm i -g maildev
CMD ["maildev"]

MailDev uses two ports, 1080 for its management console and 1025 for SMTP. These can be changed by options.

Create docker-compose.yml using the example below.

version: '3'
    container_name: mail
    build: ./
      - "1080:1080"
      - "1025:1025"

Launch the Docker container with the following command.

docker-compose up -d mail

Management Console

To access the management console, open your browser and go to http://localhost:1080.


Sending Mail

Because I’m writing this post using Windows, the example below uses Send-MailMessage command by PowerShell.

Send-MailMessage `
>> -from 'dev@localhost' `
>> -to '' `
>> -subject 'subject' `
>> -body 'test' `
>> -smtpServer 'localhost' `
>> -port 1025

Receiving Mail

You should see a new email received in the management console.


Thanks to MailDev, developers can easily test email sending functionality.

I hope you will find this post useful.

Takahiro Iwasa

Takahiro Iwasa

Software Developer at KAKEHASHI Inc.
Involved in the requirements definition, design, and development of cloud-native applications using AWS. Now, building a new prescription data collection platform at KAKEHASHI Inc. Japan AWS Top Engineers 2020-2023.