As a Laravel/PHP developer, testing emails has always been a bit of a struggle. For years, I juggled between various solutions like Mailtrap and Mailjet. While these services are great, they come with their own set of limitations, such as the need to sign up and restrictions on the number of emails you can send. This made them less than ideal for local testing.
The Search for a Better Solution
In my quest for a more efficient and hassle-free solution, I stumbled upon Mailpit. This open-source tool seemed promising, and I decided to give it a try. To my delight, setting up Mailpit was incredibly straightforward, and it has since become an indispensable part of my development toolkit.
Why Mailpit Stands Out
Mailpit is a small, fast, and low-memory email testing tool that acts as an SMTP server. It provides a modern web interface to view and test captured emails, making local email testing a breeze. Unlike other solutions, Mailpit doesn't require any sign-ups and has no limitations on the number of emails you can test.
Steps to Install Mailpit
Here's how you can get started with Mailpit:
-
Download Mailpit:
-
Visit the Mailpit GitHub repository and download the latest release for your operating system.
-
-
Run Mailpit:
- Extract the downloaded file and navigate to the directory in your terminal.
-
Run the executable file. For example, on Linux or macOS, you might use
./mailpit - On Windows, you can simply double-click the executable file.
-
Configure Your Application:
-
In your Laravel
.envfile, set theMAIL_HOSTtolocalhostandMAIL_PORTto the port Mailpit is running on (default is 1025):MAIL_HOST=localhostMAIL_PORT=1025
-
In your Laravel
- Open your web browser and navigate to http://localhost:8025 to view the Mailpit web interface. Here, you can see all captured emails and their details.
NOTE: Mailpit is only useful for testing email locally!