Videos
Check out our tutorial video series.
How to Set Up a Fake SMTP Server for Email Testing with smtp4dev: Improve email reliability and overcome issues like failed password resets.
A fake SMTP server accepts SMTP messages but does not transmit emails to external recipients. We use it for development and testing purposes.
We must test emails to overcome email-related issues like password reset, email links not working, etc.
Using a dedicated SMTP server is more reliable as we use the same code paths when testing emails using a fake SMTP server to avoid unanticipated problems. How can Gmail as your development email hurt deliverability? Sending the same Gmail inbox several times can impair your email deliverability. Another issue arises when utilizing Gmail addresses on a shared server for test emails.
smtp4 is an open-source fake SMTP server. Install Docker on your machine. For Linux or Windows, download and install a smtp4dev package. We are using Docker to set up smtp4dev for a faster process. Ensure the Docker daemon is running with the command docker info and check the Server: section.
A summary is displayed:
After launching smtp4dev for the first time, an image appears. Docker will download the image from Docker Hub and reuse it:
• --rm — removes the container when service finishes
• -it — launches the container interactively, streaming its output into the terminal.
• -p 3000:80 — map port 80 on a standard HTTP server port to port 3000 on your local machine. The smtp4dev console will be available on http://localhost:3000.
• -p 2525:25 — map port 25 in SMTP server port to port 2525 on the machine.
You can visit the application on .
Our server is running on port 2525 using smtp-cli here. You can use any SMTP client, including these libraries in your application:
Create a data.txt file with the headers and the body of the email and send: subject: Dragons Either dragons should exist entirely or fail to exist at all, he felt. A dragon only half-existing was worse than the extremes.
Send this email to our fake SMTP server:
After this the email shows up.
Limitations: It is challenging to use smtp4dev for continuous integration. The default setting might not accurately represent what you'll encounter in practice. Try MailSlurps fake smtp servers for a more flexible alternative to SMTP4Dev.
Check out our tutorial video series.
Email and SMS guides for automation and testing.
View github project code for multiple languages.
Latest posts from the MailSlurp team.
Test, build, and automate messaging with a free MailSlurp account.