[Complete Guide] How to install Mailtrain on Centos 7 with Docker

Published on 2020-01-14· Updated on 2020-02-28


Mailtrain is a very popular open-source, self-hosted, newsletter application which is built on NodeJs and MySQL. Mailtrain allows you to send bulk emails by uploading mailing lists through any of your preferred SMTP service provider.

In this tutorial, you will learn all the steps required to successfully install and integrate a free SMTP service with Mailtrain on a fresh Linux- Centos 7 server.


  1. A hosting server with a minimum of 1GB ram available for Mailtrain service. (To be at safer side, it is recommended to have slightly higher capacity)
  2. Node.js (v7+)
  3. Docker
  4. Docker compose
  5. A user account with Pepipost. If you don't have one, click here to signup and get started with 30,000 emails

Ad Image


Step 1: Install Node.js

(Skip this step, if you already have NodeJs installed)

$ sudo yum install -y gcc-c++ make
$ sudo yum install nodejs

Step 2: Clone Mailtrain git repository on your server

$ sudo git clone git://github.com/Mailtrain-org/mailtrain.git 
$ cd mailtrain

Step 3: Check docker installation

$ sudo docker -v

You can install docker using the following command (Skip, in case you have docker already installed):

$ sudo yum install docker-ce docker-ce-cli containerd.io

Step 4: Check docker-compose installation

$ sudo docker-compose -v

For installation of docker-compose follow these steps (Skip, in case you have docker-compose already installed):

  • Run this command to download the current stable release of Docker Compose:
$ sudo curl -L "https://github.com/docker/compose/releases/download/1.25.0/docker-compose-$(uname -s)-$(uname -m)" -o /usr/local/bin/docker-compose
  • Apply executable permissions to the binary:
$ sudo chmod +x /usr/local/bin/docker-compose

Step 5: Copy the file docker-compose.override.yml.tmpl to docker-compose.override.yml

$ cp docker-compose.override.yml.tmpl docker-compose.override.yml

Step 6: Up the containers

$ sudo docker-compose up -d

Step 7: Check docker status

You can check the docker container status by using the following command:

$ sudo docker ps


If you got the above output that means you have successfully installed Mailtrain service on your Linux server.

The next step is to set up a reverse proxy.

Setup reverse proxy

For Apache2:

For Installation of Apache2 server use the commands mentioned below:

$ sudo yum install httpd
$ sudo systemctl start httpd
$ sudo systemctl enable httpd

You can find the Mailtrain server configuration setting for Apache in the following path.

$ vim /var/www/html/mailtrain/setup/mailtrain-apache.conf

Note:- You need to enable Proxy Mod on Apache2 (only if you haven't enabled it yet). This can be done by using the following command:

$ httpd -M

These are the settings you will be adding in your httpd.conf file :

$ vim /etc/httpd/conf/httpd.conf
ProxyPreserveHost On
ProxyPass        "/" ""
ProxyPassReverse "/" ""
ServerName example.com
ServerAlias www.example.com

Restart the server

$ sudo service httpd restart

For Nginx:

For Installation of Nginx server use the commands mentioned below:

$ sudo yum install nginx
$ sudo systemctl start nginx
$ sudo systemctl enable nginx

You can find the Mailtrain server configuration setting for Nginx in the following path.

$ vim /var/www/html/mailtrain/setup/mailtrain-nginx.conf 

These are the settings you will be adding in your nginx.conf file :

$ vim /etc/nginx/nginx.conf
    server {
    listen 80;
    listen [::]:80;

    server_name mailtrain.org www.mailtrain.org;
    access_log /var/log/nginx/mailtrain.log;

    location / {
        proxy_set_header X-Real-IP $remote_addr;
        proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
        proxy_set_header HOST $http_host;
        proxy_set_header X-NginX-Proxy true;

        proxy_redirect off;

Restart the server:

$ sudo service nginx restart

With this, you will be able to access Mailtrain dashboard on your domain URL


Setup and Integration with SMTP

Now, you will be able to open the dashboard at http://<your-domain-address>, so login with Username: admin and Password: test

Get your Pepipost SMTP credentials

By following the below steps, you will get the Pepipost SMTP credentials:

1. Log in with your user credentials on Pepipost application

2. Open SMTP integration panel using this link

3. You will find your SMTP credentials in SMTP Relay tab

Please check the screenshot provided below for reference:

Updating Mailtrain settings

1. After successfully logging in click on admin->settings


2. In General Settings section change <Service Address (URL)> from <http://localhost:3000/> to <http://[your-domain-address]/> depending on your installation

3. Change <Admin Email> from [email protected] to your preferred sending from-address

Note:- The from-address domain name should be the registered and verified domain that you have integrated with your Pepipost account.

4. Find SMTP tab inside < Mailer Settings > section

5. Change Hostname to [smtp.pepipost.com]

6. Change Port to [25] (If you are using a hosting server that blocks port 25 you can also use port 587)

7. Change Encryption to [Use STARTTLS — usually selected for port 587 and 25] option

8. Keep the authentication checkbox disabled

8. Enter your SMTP username and Password

9. Click on [Check Mailer Config] button


10. You Should get an SMTP credential verification popup, which means your SMTP credentials are now ready to be used to send emails.


Creating a new email list

Mailtrain allows you to create an email list that can be used to send emails to a bunch of email addresses at once. This list you can use to send newsletters too.

Here are the steps to create a new email list:

1. Click on the Lists menu option

2. Enter Name, Description and click on create a list

3. In the Lists menu, you would be able to see a newly created list


Uploading email ids to the email list

Mailtrain gives two options to upload emails to the list:

1. Adding subscribers through CSV upload

a. In Lists-> [your-list-name] click on [List Actions]->[Import Subscribers]


b. Browse for the CSV file containing the list of Email addresses.

c. You can set [Categorize the imported subscribers as], as per your requirement. For importing the email list to our subscriber's list you need to keep the subscriber radio box selected.

d. [Check imported emails:] option checks if your imported email is valid else it will reject the emails that are not. The checks should be implemented if you want to filter emails according to their validity but for a large batch of email lists, it will take more time due to checkups for individual emails.


e. The CSV file that will be imported can have multiple columns namely First name, Lastname, EmailId, Timezone


f. Click on Next button

g. Depending upon the number of Parameters in the CSV files you will get multiple dropdowns to import your uploaded data. Select the fields you want to import and click on the Start Import button.

h. After the import your email list will be populated, if there were any rejected email ids they will be listed with the reason for rejection.

i. You can edit, delete and blacklist the email address in the email list.


2. Adding subscriber through Add subscriber panel

a. In Lists-> [your-list-name] click on [List Actions]->[Add Subscribers]

b. Enter User details

c. Click on Subscribe

Creating Template

Mailtrain has a template creation feature that allows us to create an HTML email template in the mail train panel itself. To create a new email template follow these steps:

1. Click on Templates menu option

2. Enter template name, Select your desired HTML editor (in this tutorial GrapeJS is used), Select HTML Template and description

3. Click on Create Template button

4. With this, your Template will be created and you will be redirected to the edit template screen, now you can edit the newly created email template.

5. Click on open GrapeJS button to edit using GrapeJS UI panel

6. After making necessary changes click on [save] and then close the panel


Create a new campaign

Campaigns in Mailtrain allows us to send relative emails to the targeted audience.

To create a new email campaign please follow these steps:

1. Click on [Campaigns] menu option

2. Go to [Create Campaign] -> [Regular Campaigns]

3. Enter Name of your Campaign and Campaign Description

4. Select the email list which you have created in the previous steps

5. Select an Email template

6. Enter from the address of the campaign with a valid domain name

7. Enter the Subject line for your campaign

8. Click on [Create Campaign]

9. You can edit the template by clicking the Template tab and editing the template either directly or through your template editor.

10. Adding attachments to the email body can easily be done by clicking on [Attachments tab] -> [Add Attachment], Browse the attachment and click on [Upoload] button.


Send Email

1. Go to Campaigns->[Your-campagin]

2. Click on [Send to subscribers] button to send emails to the set email list.


3. After the campaign has been successfully completed, you will be able to see the status of the current campaign emails.


4. You can click on the [Reset] button to reset the status of the current campaign so that you can track your campaign without considering previously ran campaigns. This will reset all of the campaign data regarding earlier campaign runs.

5. Press continue to rerun the campaign without resetting the campaign status.

For Large Import list

1. For the list of 100000 email list, our server took around less than 20 minutes to import emails to our list.

2. You need to disable validation in order to speed up the import process

3. With Mailtrain, it also helps to have change [Max connections] and [Max messages] settings in Advance mailer settings. This will help reduce the time taken to send a large email list.

Updating Advanced Mailer settings

i. Find the [Advanced Mailer settings] section in admin->settings (admin is your username).

ii. There are three options in this section [Max connections],[Max messages] and [Throttling].

iii. [Max connections] is the maximum number of open connections that will be sending emails to your email server. By default these are set to 5, you can change this to greater value for a large email batch.

iv. [Max messages] is the number of emails batches that are sent from each connection to the SMTP server.

v. [Throttling] limits the maximum number of emails you can send in an hour. So in case you enter 5000 then Mailtrain will send not more than 5000 emails per hour.


4. With [Max connections] set to 50, [Max messages] set to 1000 you'll able to achieve to send 100000 in just over 50 minutes but results may vary depending on your system and setup.


By following the above steps, you have now successfully installed Mailtrain and are ready to send bulk emails through Pepipost SMTP services. You can easily create HTML email templates using template generator and run Email campaigns on the preferred email lists.

Grade My Email
Check your spam now?

Netcorecloud's toolkit is the solution to all your email problems.

Hitesh Pandey💻

Full Stack Developer, Pepipost

🥑 Developer Evangelist | 🥇Email Geek

You can also explore

Netcore connects & unifies your data across all sources, connects to your marketing channels and provides you with control over AI Powered automation and personalization.

Join over 30,000
Fellow Marketers

Get expert marketing tips straight to your inbox and become a better marketer. Subscribe to our Blog.
Request Demo
Get Started Now