Mailpit

After reading the article, you can create your own email sandbox environment (fake smtp server).

About

Mailpit is a free test environment for email sendings. When you need to test email sendings without use real email accounts and SMTP server, Mailpit is the best open-source solution for it. It comes with default two ports (8025 for the web UI and 1025 for SMTP). Additionally, it has an API for advanced use cases.

It is a free and self-hosted solution. You can send thousands test emails with Mailpit.

Installation

MacOS (Brew)

If you’ve brew package manager, you can install with it;

brew install mailpit

If you want to start Mailpit as a service, you can apply the follow command after the installation.

brew services start mailpit

Linux & MacOS (Bash Script)

You can run the following bash script on MacOS if you dont have not brew package manager.

sudo bash < <(curl -sL https://raw.githubusercontent.com/axllent/mailpit/develop/install.sh)

After the installation, if you want to start Mailpit as a service, you can follow the instructions on the systemd integration or the supervisor integration page.

Windows

You can use static binary file for Windows. Static binaries can always be found on the releases page. The mailpit binary can extracted and copied to your $PATH, or simply run as ./mailpit.

Other Options

Other installation options are using with docker or building from source.

Testing

SMTP Test

Create a text file email.txt with the following contents.

From: [email protected]
To: [email protected]
Subject: Test Email

Hello, world.
This is a test email.

Then run the following command to send your test email:

mailpit sendmail < email.txt

Accessing to Mailpit Web UI

You can access to web UI via http://localhost:8025

Screenshots of Mailpit

Email Mailpit Email

Inbox Mailpit Inbox

Usage

Mailpit for Laravel

You can update your .env file as the below.

MAIL_MAILER=smtp
MAIL_HOST=localhost
MAIL_PORT=1025
MAIL_USERNAME=null
MAIL_PASSWORD=null
MAIL_ENCRYPTION=null
MAIL_FROM_ADDRESS="[email protected]"
MAIL_FROM_NAME="${APP_NAME}"

Alternatives to Mailpit