Log inSign up

Mautic campaigns and email marketing on your own server

Start the official mautic/mautic image as a web container and a worker container next to MariaDB with Docker Compose, publish the web container on 127.0.0.1:8080, and serve it through Nginx with a Let's Encrypt certificate. Complete the browser installer, set an SMTP relay DSN on port 587 for sending, and add cron entries for segments, campaigns and broadcasts. Expect to need 4 GB of memory for a working list of contacts.

Topic: Self-hosted apps · Tested on: Ubuntu 24.04 and 22.04, Debian 12 and 13 · Updated 2026-12-03

What do you need to run Mautic?

Mautic is a PHP and Symfony application with a MySQL or MariaDB database, a message queue worker for sending, and scheduled console commands that rebuild segments and move contacts through campaigns. Give it 2 vCPU and 4 GB of memory; large segment rebuilds are the heaviest task.

  • Docker and Compose, via Docker Engine or the Docker app image.
  • A hostname like mautic.example.net pointing to 198.51.100.24 and 2001:db8:4f2a::24.
  • An SMTP relay or sending service account; marketing mail volume makes a relay essential.

Mautic publishes image tags by major version and flavour, such as 6-apache. Check Docker Hub for the newest major tag before you begin and use it everywhere below.

How do you write the environment and compose files?

Keep secrets in .env and share one set of volumes between the web and worker roles.

mkdir -p ~/mautic && cd ~/mautic
mkdir -p data/config data/logs data/media/files data/media/images
nano .env
MYSQL_ROOT_PASSWORD=root-random-value
MYSQL_DATABASE=mautic
MYSQL_USER=mautic
MYSQL_PASSWORD=db-random-value

Then create compose.yaml:

x-mautic: &mautic
  image: mautic/mautic:6-apache
  restart: always
  env_file: .env
  depends_on:
    - db
  volumes:
    - ./data/config:/var/www/html/config
    - ./data/logs:/var/www/html/var/logs
    - ./data/media/files:/var/www/html/docroot/media/files
    - ./data/media/images:/var/www/html/docroot/media/images
services:
  db:
    image: mariadb:11.4
    restart: always
    env_file: .env
    volumes:
      - mautic-db:/var/lib/mysql
  web:
    <<: *mautic
    ports:
      - "127.0.0.1:8080:80"
    environment:
      DOCKER_MAUTIC_ROLE: mautic_web
      MAUTIC_DB_HOST: db
      MAUTIC_DB_PORT: 3306
      MAUTIC_DB_DATABASE: mautic
      MAUTIC_DB_USER: mautic
      MAUTIC_DB_PASSWORD: db-random-value
      MAUTIC_TRUSTED_PROXIES: '["0.0.0.0/0"]'
  worker:
    <<: *mautic
    environment:
      DOCKER_MAUTIC_ROLE: mautic_worker
      MAUTIC_DB_HOST: db
      MAUTIC_DB_PORT: 3306
      MAUTIC_DB_DATABASE: mautic
      MAUTIC_DB_USER: mautic
      MAUTIC_DB_PASSWORD: db-random-value
volumes:
  mautic-db:

The trusted proxies setting lets Mautic believe the HTTPS scheme that Nginx reports. The official docker-mautic repository has fuller examples, including a dedicated cron role, if you prefer to follow those.

How do you start the containers and verify them?

Start the database first, then the application roles, and look at the web log.

cd ~/mautic
docker compose up -d db
sleep 15
docker compose up -d
docker compose ps
docker compose logs --tail 30 web
curl -sI http://127.0.0.1:8080 | head -n 1

A redirect toward the installer means the web role is ready. The image prints the Mautic version in its log; later docker compose exec web php bin/console --version reports it too.

How do you publish Mautic with HTTPS?

Terminate TLS in Nginx and forward to port 8080 with the usual forwarded headers. Tracking pixels and forms are loaded from other websites, so HTTPS is required for them to work on secure pages.

sudo apt install -y nginx certbot python3-certbot-nginx
sudo tee /etc/nginx/sites-available/mautic >/dev/null <<'EOF'
server {
    listen 80;
    listen [::]:80;
    server_name mautic.example.net;
    client_max_body_size 64M;
    location / {
        proxy_pass http://127.0.0.1:8080;
        proxy_set_header Host $host;
        proxy_set_header X-Real-IP $remote_addr;
        proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
        proxy_set_header X-Forwarded-Proto $scheme;
        proxy_read_timeout 300s;
    }
}
EOF
sudo ln -s /etc/nginx/sites-available/mautic /etc/nginx/sites-enabled/
sudo nginx -t && sudo systemctl reload nginx
sudo certbot --nginx -d mautic.example.net
sudo ufw allow OpenSSH && sudo ufw allow 'Nginx Full' && sudo ufw enable

Caddy fits here too with reverse_proxy 127.0.0.1:8080 (Caddy HTTPS).

How do you complete the Mautic installer?

Go to https://mautic.example.net: the installer checks the environment, then asks for database details (host db, port 3306, database mautic, user mautic and its password), then for the admin user. Finish, sign in, and open Settings, Configuration, System Settings to confirm the Site URL is the HTTPS address. Its config is written to data/config on the host, so it survives container upgrades.

How do you configure sending through a relay?

Under Settings, Configuration, Email Settings, set the transport DSN to your relay with port 587, for example scheme smtp, host smtp.relay.example.net, port 587, user and password, and fill in the From name and address. Send a test email from the same screen. Marketing mail depends on reputation, so use a relay or sending service that permits bulk mail, publish SPF, DKIM and DMARC records (SPF, DKIM and DMARC), and include unsubscribe links. Port 25 is not promised for direct delivery; ask support by ticket before planning your own outgoing mail server, and see SMTP relay for apps.

Which scheduled jobs does Mautic need?

Segments, campaigns and scheduled broadcasts only advance when their console commands run. Add them to the host crontab of your sudo user, calling into the web container:

crontab -e
*/10 * * * * cd ~/mautic && docker compose exec -T web php bin/console mautic:segments:update --batch-limit=900 >/dev/null 2>&1
*/10 * * * * cd ~/mautic && docker compose exec -T web php bin/console mautic:campaigns:update >/dev/null 2>&1
*/5 * * * * cd ~/mautic && docker compose exec -T web php bin/console mautic:campaigns:trigger >/dev/null 2>&1
*/15 * * * * cd ~/mautic && docker compose exec -T web php bin/console mautic:broadcasts:send >/dev/null 2>&1
0 3 * * * cd ~/mautic && docker compose exec -T web php bin/console mautic:import >/dev/null 2>&1

Stagger the minutes if several jobs collide on a small server. The worker container consumes the email queue, so messages leave without a cron entry of their own. Timing syntax is explained in the cron guide.

How do you back up, upgrade and troubleshoot Mautic?

cd ~/mautic
docker compose exec -T db sh -c 'mariadb-dump -u root -p"$MYSQL_ROOT_PASSWORD" mautic' | gzip > mautic-$(date +%F).sql.gz
tar czf mautic-data-$(date +%F).tgz data .env

For upgrades, change the tag in compose.yaml only after reading the release notes, then docker compose pull && docker compose up -d; the web role applies migrations at start. Common issues:

  • Mixed content or http links: the trusted proxies setting or the Site URL is wrong.
  • Contacts never enter a campaign: the segment and campaign cron jobs are not running; run one by hand and read its output.
  • Emails stay queued: inspect docker compose logs worker.
  • Memory exhaustion during segment builds: lower --batch-limit or move to a larger plan.

Plans that fit this guide

Base city prices. Every plan includes a dedicated IPv4 address, IPv6, full root and all 18 images.

All prices
PlanFits becauseSizeMonthlyOrder from
A2-4a modest contact list2 vCPU, 4 GB RAM, 100 GB NVMe$14.40/mo$43.20 for 3 months
A4-8large segments and campaigns4 vCPU, 8 GB RAM, 180 GB NVMe$28.80/mo$86.40 for 3 months

Questions about Mautic marketing automation

Is Mautic free to self-host?

Yes. Mautic is open source under the GPLv3 license, with no limit on contacts in the self-hosted version.

Can I install Mautic without Docker?

Yes. Mautic documents a Composer-based install on a PHP web server; check that your distribution PHP version matches the Mautic release you choose.

Why do I need a relay for marketing email?

Bulk mail needs a sending reputation and feedback handling that a fresh server IP lacks, and port 25 is not guaranteed to be open. A relay on port 587 handles delivery.

How do I track visitors on my website?

Paste the tracking script from Settings, Tracking Settings into your site. Visits are then linked to known contacts after they fill a Mautic form.

Can Mautic and my CRM share contacts?

Mautic includes plugins for several CRMs and a REST API for custom syncs, for example with Odoo.