DEV Community

Abdul Wahid Kahar
Abdul Wahid Kahar

Posted on

Running Mailpit for SMTP and UI on MacOS

Mailpit is a tool for handling fake email deliveries, useful during application development. This tutorial will guide you through setting up and running Mailpit on MacOS with SMTP and UI configuration.

Step 1: Install Mailpit
Download and install Mailpit from the official GitHub repository. Choose the appropriate binary for MacOS.

Step 2: Running Mailpit
To start Mailpit, use the following command:

mailpit --smtp 0.0.0.0:1025 --listen 0.0.0.0:8025
Enter fullscreen mode Exit fullscreen mode

This command starts the SMTP server on port 1025 and the web UI on port 8025.

SMTP: 0.0.0.0:1025 handles email delivery.
UI: 0.0.0.0:8025 allows you to view sent emails.
If you encounter an error stating that the address is already in use, ensure no other service is running on the same port. You can use a different port if needed by adjusting the command.

Step 3: Configuring Laravel Mail Settings
In your Laravel .env file, configure the mail settings:

env

MAIL_MAILER=smtp
MAIL_HOST=127.0.0.1
MAIL_PORT=1025
MAIL_USERNAME=null
MAIL_PASSWORD=null
MAIL_ENCRYPTION=null
MAIL_FROM_ADDRESS="hello@example.com"
MAIL_FROM_NAME="${APP_NAME}"
Enter fullscreen mode Exit fullscreen mode

This configuration directs Laravel to send emails through Mailpit's SMTP server.

Step 4: Testing Email Sending
When your application sends an email, you can view it in the Mailpit UI by navigating to:

http://localhost:8025
This will display all emails sent by your application.

Troubleshooting
Connection Refused: Ensure Mailpit is running on the correct port (1025 for SMTP).
Port Conflict: If you encounter a "bind: address already in use" error, change the port in the command or stop the conflicting service.
That's it! You've successfully set up Mailpit to handle and display fake email deliveries in your development environment.

Top comments (0)