How to Self-Host an Email List Manager with Listmonk

    In this tutorial, you will learn how to self-host an email list manager. One of the most popular open-source options for doing this is listmonk which is what we’ll be using.

    The only thing you’ll need is an SMTP email provider—Gmail or Google Workspace will work just fine too. As long as your email provider is credible, you shouldn’t have any issues with email deliverability since listmonk actually doesn’t send any emails itself. Instead it uses the SMTP service to do that.

    Although the tutorial will guide you step-by-step in setting up the mailing list software, some knowledge of server administration will be necessary for ongoing maintenance and security as these topics are not covered here.

    Seem Too Complicated?

    Self-hosting your own email list manager is no easy task. If you’re not up for the challenge, Omnisend is an affordable email marketing services that has a generous free plan. You don’t even need a credit card to get started.

    With Omnisend, there is no responsibility of ongoing server security and maintenance. Not only that, but the set of features that Omnisend provides are not only much more advanced, but user-friendly too.

    Try Omnisend Free

    1. Server Setup

    There are a variety of ways you can self-host listmonk. That includes on your own hardware at home. In this tutorial, we’ll be hosting listmonk on a cloud server. Feel free to use any cloud provider—we’ll be using Kamatera.

    Get $100 Cloud Credits Free

    While you can install listmonk on the following operating systems, in this tutorial we will be using Ubuntu 24.04.

    The above links are for listmonk 4.1.0 which is the latest version at the time of this tutorial. Check the official listmonk repository on Github for the most up-to-date release.

    2. Connect Your Domain Name (optional)

    While you can use the IP address of your server throughout this tutorial, you can also associate your server with a domain name. This can be done with a DNS A record.

    Find the DNS settings for your domain name at your domain registrar. My domain name tonyteaches.tech is currently registered with Squarespace Domains.

    Add an A record where the value is the IP address of your server. If you want a subdomain like mail.tonyteaches.tech, then type mail as the host value.

    3. Server Configuration

    As the root user, let’s first update and upgrade the operating system of the server.

    apt update && apt upgrade

    Instead of using root, let’s create a user called listmonk.

    adduser listmonk

    4. Download and Configure listmonk

    As the listmonk user, download the latest release of listmonk (as mentioned above) onto your server.

    su - listmonk
    wget https://github.com/knadh/listmonk/releases/download/v4.1.0/listmonk_4.1.0_linux_amd64.tar.gz
    tar -zxf listmonk_4.1.0_linux_amd64.tar.gz
    rm listmonk_4.1.0_linux_amd64.tar.gz

    Create a new listmonk configuration file.

    ./listmonk --new-config

    Edit the configuration file with the text editor of your choice. We’ll be using vim in this tutorial.

    vim config.toml

    Customize the configuration file by updating the address from localhost:9000 to the IP address or domain name of your server. Also for security reasons, change the default database password from listmonk to something that is more secure.

    [app]
    # Interface and port where the app will run its webserver. The default value
    # of localhost will only listen to connections from the current machine. To
    # listen on all interfaces use '0.0.0.0'. To listen on the default web address
    # port, use port 80 (this will require running with elevated permissions).
    address = "mail.tonyteaches.tech:9000"

    # Database.
    [db]
    host = "localhost"
    port = 5432
    user = "listmonk"
    password = "listmonk"

    # Ensure that this database has been created in Postgres.
    database = "listmonk"

    ssl_mode = "disable"
    max_open = 25
    max_idle = 25
    max_lifetime = "300s"

    # Optional space separated Postgres DSN params. eg: "application_name=listmonk gssencmode=disable"
    params = ""

    5. Database Setup

    As the root user, install the PostgreSQL software package.

    exit
    apt install postgresql

    As the postgres user, create a user and database for listmonk to use.

    su - postgres
    createuser listmonk -P --interactive
    createdb -O listmonk listmonk
    exit

    6. Install listmonk

    As the listmonk user, install and run listmonk.

    su - listmonk
    ./listmonk --install
    ./listmonk

    At this point, you can access listmonk in a web browser. Click the Login button as create a new user as instructed.

    7. Create a listmonk System Service

    Rather than running the listmonk binary from the command line, let’s create a system server for it. This way, the listmonk application will automatically start up when the server does.

    vim /etc/systemd/system/listmonk.service

    In the listmonk.service file, add the following being sure to update any paths to match your system.

    [Unit]
    Description=Listmonk service
    After=network.target
    
    [Service]
    WorkingDirectory=/home/listmonk
    ExecStart=/home/listmonk/listmonk
    User=listmonk
    Restart=always
    
    [Install]
    WantedBy=multi-user.target

    Enable and start the listmonk service with systemctl.

    systemctl enable listmonk
    systemctl start listmonk
    systemctl status listmonk

    Now the listmonk application will automatically run in the background.

    Leave a Reply

    Your email address will not be published. Required fields are marked *