Installing Mailtrain on Fedora Server Latest

Mailtrain is a self-hosted newsletter application built on Node.js, MongoDB, and Redis. In this tutorial, we'll go through the process of installing Mailtrain on a Fedora Server Latest system.

Prerequisites

Before proceeding with the Mailtrain installation, ensure your system has the following prerequisites:

If you don't have Node.js, MongoDB, and Redis installed, you can follow this guide on how to install LEMP stack on Fedora 34.

Step 1 - Clone the Mailtrain source code

The first step of installing Mailtrain is to clone its source code from its GitHub repository. To do this, run the following command:

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

This command clones the entire source code of Mailtrain into a directory named mailtrain on your Fedora server.

Step 2 - Install Mailtrain dependencies

Before running Mailtrain, you must install its dependencies. To do so, navigate to the mailtrain directory and run the following command:

$ npm install

This command installs all the required dependencies listed in the package.json file.

Step 3 - Configure Mailtrain

Next, configure Mailtrain by creating a .env file with the following environment variables:

# Port on which Mailtrain server will listen
PORT=3000

# MongoDB connection URL
MONGODB_URL=mongodb://localhost/mailtrain

# Redis connection URL
REDIS_URL=redis://localhost:6379

# Change this to a random 32-character string
SECRET=your-random-secret

# Domain of the Mailtrain server
MAILTRAIN_HOST=mail.example.com

# Mail server settings - use your own mail server settings
MAIL_FROM_ADDRESS=myusername@example.com
SMTP_HOST=mail.example.com
SMTP_PORT=587
SMTP_USER=myusername@example.com
SMTP_PASSWORD=mypassword

You should modify the values of these environment variables according to your requirements.

Step 4 - Run Mailtrain

To run Mailtrain, navigate to the mailtrain directory and run the following command:

$ npm start

This command starts the Mailtrain server and listens on localhost:3000.

Step 5 - Configure Nginx as a reverse proxy (optional)

If you want to access Mailtrain from a public URL, you can configure Nginx to act as a reverse proxy. To do this, create an Nginx configuration file in the /etc/nginx/conf.d/ directory with the following content:

server {
    listen 80;
    server_name mail.example.com; # change this to your domain name

    location / {
        proxy_pass http://localhost:3000;
        proxy_http_version 1.1;
        proxy_set_header Upgrade $http_upgrade;
        proxy_set_header Connection 'upgrade';
        proxy_set_header Host $host;
        proxy_cache_bypass $http_upgrade;
        proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
        proxy_set_header X-Real-IP $remote_addr;
    }
}

Save the file and restart Nginx:

$ sudo systemctl restart nginx

Now, you can access Mailtrain from http://mail.example.com.

Conclusion

In this tutorial, you learned how to install Mailtrain on a Fedora Server Latest system. With Mailtrain, you can easily send newsletters and email campaigns to your subscribers.

If you want to self-host in an easy, hands free way, need an external IP address, or simply want your data in your own hands, give IPv6.rs a try!

Alternatively, for the best virtual desktop, try Shells!