Install a Powerful Mailing Service Mailtrain With Docker Compose

A Self Hosted Marketing Tool, Free and Open Source

Post cover image displaying the Mailtrain logo
Your Own Marketing Tool!

Mailtrain is an excellent self-hosted mailing service where you can manage your newsletters and campaigns via user list management and user segmentation with various email template editors, automation, and much more, all of this packaged in Mailtrain.

In this post, We will be installing Mailtrain with Docker Compose.

Table of contents


  • Docker
  • Docker Compose
  • SMTP account for mailing use (Optional for installation)
  • A text editor of your choice

Setup Docker Compose File

We will start by creating our empty docker-compose.yml file:

touch docker-compose.yml

Now we need to describe our services in the file, we can put the following content:

version: "3"

    image: mailtrain/mailtrain:latest
      - "3000:3000"
      - "3003:3003"
      - "3004:3004"
      - ./mailtrain-files:/app/server/files

    image: mariadb:10.4
      - MYSQL_ROOT_PASSWORD=mailtrain
      - MYSQL_DATABASE=mailtrain
      - MYSQL_USER=mailtrain
      - MYSQL_PASSWORD=mailtrain
      - ./mysql-data:/var/lib/mysql

    image: redis:5
      - ./redis-data:/data

    image: mongo:4-xenial
      - ./mongo-data:/data/db

This docker-compose file will persist the services data in the local directory if we don't like that we can add the following volume settings (then we need to remove ./ in front of all the volume declarations in the file):


Start and Verification

Once the docker-compose.yml file is set up, we can start our server:

docker-compose up -d

This will create our services along with the persistence folders.

Give it a minute or two to initialize then go to http://localhost:3000 and use admin/test as your credentials.

Now we are good to go but before we dive deep into it one might be curious why there are 3 endpoints defined in the mailtrain service, let me quote why here:

Mailtrain creates three URL endpoints, which are referred to as "trusted", "sandbox" and "public". This allows Mailtrain to guarantee security and avoid XSS attacks in the multi-user settings. The function of these three endpoints is as follows:
trusted - This is the main endpoint for the UI that a logged-in user uses to manage lists, send campaigns, etc.
sandbox - This is an endpoint not directly visible to a user. It is used to host WYSIWYG template editors.
public - This is an endpoint for subscribers. It is used to host subscription management forms, files and archive.

More info on Mailtrain preparations can be found here.

After a successful login, we can start navigating the UI, I believe the first step we need to do is configuring the SMTP settings so we can start sending emails (under Administration > Send configurations).


In summary, there is a decent learning curve in the Mailtrain platform but I think it's worth the time and effort since this is a powerful mailing service with tons of customization to be done for free.


As always, I hope you learned something.

Found this useful? feel free to share it with your friends.

Join the newsletter from to notify you of new posts and updates.

Like the post? consider buying us a coffee ❤️.