Lukasz Skowroński - Senior Solutions Architect
30 Apr 2025
Every developer working with Digital Experience Platforms like Sitecore, sooner or later, meets a need to add some email communication with the visitors or better-known contacts. It may be as simple as sending a notification after submitting the form or purchasing confirmation. It may also be a more complex case of an executed marketing automated plan that triggers an email campaign.
With local Sitecore instances, developers usually use external SMTP accounts, such as another Gmail account, to safely play with multiple test emails.
Sometimes they use fake SMTP servers provided by multiple Saas providers, which is unsafe when your emails contain some data that should not be disclosed.
There are also available servers that you can install locally, just like any other application, and connect to them from your Sitecore instance.
But why use all of these options when you can set up your local SMTP server with Docker in a few minutes?
If you are old enough you may know already name of the tool from the title – smtp4dev.
Years ago, it was one of the most popular tools for setting up a local SMTP server that could be installed locally and used during the development process.
Now, it is possible to add it to your containerized environment. Documentation of that tool is available on the github page: https://github.com/rnwood/smtp4dev
From the start UI shows what you can expect from that tool:
Thanks to smtp4dev you will be able to see all the emails being sent through the server and also content of every particular email.
To be clear, this is a fake server, which means that none of the emails will ever be delivered; all of them will stop on the server level.
Docker images are publicly available on the hub.docker.com page: https://hub.docker.com/r/rnwood/smtp4dev
If you do not have experience with Docker and Sitecore, you should start with great tutorial provided by Sitecore available in official documentation:
When you are familiar with basic setup you can start playing with Sitecore compose file and add our fake smtp server to the local configuration. In my case I decided to modify configuration of XP0 topology – inside xp0 folder I opened docker-compose.yml file
and added “smtp4dev” container to the list of containers:
In my case a new container was added at the end of the list, but it does not make any difference. What you should focus on at this point is name of the container and the ports that are exposed through the Docker host.
When this container is up and running you gain access to the SMTP server as also to web application presenting data received by the SMTP server.
You can access application with url: http://localhost:5000 (pay attention to protocol, it is not https).
More interesting is a mapping of port 2525 into port 25. Thanks to this mapping you can use your SMTP server from the inside of Docker network as also from any other network (for instance separate application running outside of Docker).
If you want to use SMTP server from the outside of Docker, you have to use:
If you want to use SMTP server from the inside of Docker (for instance your Sitecore CM), you have to use:
Because this is a fake SMTP server, it will accept any username and password.
Now when you have your SMTP server ready, you have to connect your Sitecore to it. You can easily make your Sitecore image to load the configuration by mounting additional volume to the container.
First, create a configuration file with a structure:
Then put it inside your local App_Config folder (can be named differently) and then adjust volumes definition to mount your folder inside “Include” folder of Sitecore:
Starting from now, whenever your containers start, configuration will be loaded and you will be using your custom SMTP server. You can now easily test your configuration, for instance by setting up save action in any of your forms.
I hope that you learned today a new useful tool that will allow you to play with your emails without sending those outside of your environment. With this article once again we prove that Docker lets you quickly set up many tools that can be available for you in just a few
I have been awarded with the Sitecore MVP award seven times (the first time in 2017) for my continued support of the Sitecore Community. Besides blogging, as a Sitecore Community member, I organize all of the Sitecore User Group meetups in Poland. Since 2021 I have helped to organize the Sitecore User Group Conference (SUGCON) as one of the co-organizers.
Share on social media