This time, you will learn how to install MailTrain App on Ubuntu / Debian
Mailtrain is a free, self-hosted open-source newsletter and email marketing application. It is developed using Node.JS and it uses MySQL/MariaDB as for Database. Mailtrain provides many features like list management, Template Editor, RSS Campaigns, Custom Fields, Email Automation, High-Level Encryption. If someone is starting and has a long list of subscribers, Mailtrain is a suitable option for anyone who is starting as it also provides a decent web based console for management.\
Requirements :
- 1GB or more RAM (Depending upon the usage and size of the subscribes and number of outgoing mails)
- 2vCore CPU (For optimal performance and for no hiccups)
- Debian 9 or greater OR Ubuntu 18.04 or great
Step 1 : Update your server
First step is to update your VPS server for newer packages and security releases for your Distribution. Run the following commands to update your server
apt-get update -y
apt-get upgrade -y
Step 2 : Install NodeJS
Second step is to install NodeJS, The MailTrain application is based on NodeJS so we will need to install it, Before installing it we need to add its PPA in our OS, Here we will install the tested and stable release, Run the following command :
curl -sL https://deb.nodesource.com/setup_14.x | sudo bash –
Now the PPA is installed, Directly install NodeJS
apt-get install nodejs
apt-get install gcc g++ make
Run the following commands to check whether that NodeJS and NPM is installed or not
npm -v
node -v
Step 3 : Install MariaDB/MySQL
Since MailTrain is based on MySQL/MariaDB we can directly install it, Since its available by default in the OS. Run the following commands to install
apt-get install mariadb-server mariadb-client
Run the following command to complete the MariaDB Installation:
mysql_secure_installation
Follow the prompt as shown in the text or in the picture :
Set root password? [Y/n] Y
Remove anonymous users? [Y/n] Y
Disallow root login remotely? [Y/n] n
Remove test database and access to it? [Y/n] Y
Reload privilege tables now? [Y/n] Y
Enable MariaDB Service on boot and restart it :
systemctl enable mariadb.service
systemctl restart mariadb.service
Step 3 (B) : Creating a Database
Run the following command to login to the MariaDB Server and use the password which you set in the above step
mysql -u root -p
Run the following commands to create Database & User :
CREATE DATABASE mailtrain;
CREATE USER ‘mailtrainuser’@’localhost’ IDENTIFIED BY ‘passwordhere’;
GRANT ALL PRIVILEGES ON mailtrain.* TO ‘mailtrainuser’@localhost;
exit
Step 4 : Download & Install Mailtrain App
Everything is installed for Mailtrain to work, NodeJS & MariaDB with database, So now we can directly download Mailtrain app from the github source and install it. Run the following commands:
apt-get install unzip
wget https://github.com/Mailtrain-org/mailtrain/archive/master.zip
unzip master.zip
mv mailtrain-1 mailtrain
Change the name of the default.toml to production.toml using the following command
cd mailtrain cp /config/default.toml /config/production.toml nano /config/production.toml
And edit the content as shown in the picture ::
After this, Run the following command to install all the required dependencies. This command will take a bit time to complete:
cd ~/mailtrain
npm install –production
Run the following command to start the server:
cd ~/mailtrain
NODE_ENV=production npm start
After running the command you will see a output like this :
Now, You can access your MailTrain GUI at http://localhost:3000.
The default password for the admin user is
Username : admin
Password : test
Conclusion :
You have installed Mailtrain application on Ubuntu or Debian Server, This tutorials assumes you are root!