Self-Host Your Email Infrastructure for $5/Month
Pranav Patel
Co-founder·14 min read
On this page

A complete guide to running your own transactional email stack with Reloop on a cheap VPS (SMTP, REST API, analytics dashboard, and bounce handling) for less than a cup of coffee a month.
The math on managed email providers
At 10,000 emails/month: SendGrid charges $19.95. Resend charges $20. Mailgun charges $15. Postmark charges $15.
Scale to 50,000/month and you're looking at $19.95 (SendGrid Essentials), $20 (Resend), or $35 (Mailgun). Per month. Every month. With per-email overages if you spike.
A Hetzner CAX11 ARM VPS costs €3.29/month (~$3.50). With a custom domain and proper DNS, running Reloop on that server gives you everything those managed providers offer (the REST API, the analytics dashboard, SMTP relay, bounce handling, webhook events, template management) for a fixed cost that doesn't scale with volume.
This guide walks you through the full setup, from provisioning the server to sending your first production email.
What you get with a self-hosted Reloop stack
Prerequisites
Before starting, you need:
- A VPS provider account (we'll use Hetzner, but DigitalOcean, Linode, OVH, or Vultr all work)
- A domain name with DNS access (Cloudflare DNS is free and recommended)
- Basic comfort with SSH and the Linux command line
- About 45 minutes
Step 1: Choose and provision your server
Minimum specs
For Hetzner specifically: the CAX11 (ARM, 2 vCPU, 4 GB RAM, 40 GB SSD) at €3.29/month is the sweet spot. ARM instances have excellent price/performance for this workload.
Provision on Hetzner
- Go to hetzner.com/cloud and create an account
- Create a new project
- Click Add Server
- Select location closest to your users (Nuremberg/Helsinki for EU, Ashburn for US East)
- Image: Ubuntu 22.04
- Type: CAX11 (ARM)
- Add your SSH public key (or create one:
ssh-keygen -t ed25519 -C "your-email") - Click Create & Buy Now
Note your server's public IP address. You'll need it shortly.
Important: check port 25
Many VPS providers block outbound SMTP (port 25) by default to prevent spam abuse. Hetzner blocks it initially. Before setting up email, request port 25 to be opened through Hetzner's support panel. They typically approve within a few hours for legitimate use cases. For what each port is for, see SMTP ports explained.
While you wait, continue with DNS setup.
Step 2: Configure DNS
Good DNS setup is what separates a self-hosted email stack that lands in the inbox from one that goes straight to spam. Do this before installing anything.
A record: point your domain to the server
1Type: A2Name: mail (or reloop, or whatever subdomain you prefer)3Value: YOUR_SERVER_IP4TTL: 300This creates mail.yourdomain.com pointing to your server.
PTR record (reverse DNS)
This is critical and often overlooked. A PTR record is the reverse of an A record: it maps an IP address back to a hostname. ISPs check PTR records to verify that the IP sending email is who it claims to be.
In Hetzner's console, go to your server → Networking → Set rDNS and set it to mail.yourdomain.com (matching your A record).
Most spam issues from fresh self-hosted setups come from missing PTR records. Don't skip this.
MX record: for receiving email (optional but recommended)
If you want to receive email (not just send), add an MX record:
1Type: MX2Name: @ (root domain)3Value: mail.yourdomain.com4Priority: 105TTL: 3600SPF, DKIM, DMARC
You'll add these after Reloop is running. The dashboard gives you the exact records to add. If you want to know what each record does first, read our SPF, DKIM and DMARC setup guide. For now, add a placeholder SPF:
1Type: TXT2Name: @ (root domain)3Value: v=spf1 ~all4TTL: 300You'll update this once Reloop is running.
Step 3: Install Docker and Docker Compose
SSH into your server:
ssh root@YOUR_SERVER_IPInstall Docker:
1# Update package index2apt update && apt upgrade -y3
4# Install Docker5curl -fsSL https://get.docker.com | sh6
7# Install Docker Compose plugin8apt install docker-compose-plugin -y9
10# Verify11docker --version12docker compose versionStep 4: Deploy Reloop
Clone the repository
git clone https://github.com/reloop-labs/reloop /opt/reloopcd /opt/reloopConfigure environment variables
cp .env.example .envnano .envThe critical variables to set:
1# Your sending domain2MAIL_DOMAIN=mail.yourdomain.com3
4# A secure random string for API auth5RELOOP_API_SECRET=your-very-secure-random-string-here6
7# Database (Reloop includes Postgres in the compose file)8DATABASE_URL=postgresql://reloop:reloop@postgres:5432/reloop9
10# Your server's public IP or domain11PUBLIC_URL=https://mail.yourdomain.com12
13# SMTP settings (Reloop IS the SMTP server, but it needs your hostname)14SMTP_HOSTNAME=mail.yourdomain.comGenerate a secure API secret:
openssl rand -base64 32Start the stack
docker compose up -dThis pulls all images and starts:
- Reloop API server (port 3000)
- Reloop dashboard (port 3001)
- Reloop SMTP server (port 25, 587)
- PostgreSQL database
- Redis (for the job queue)
Check all services are healthy:
docker compose psdocker compose logs --tail=50Step 5: Set up SSL with Caddy
You need HTTPS for the dashboard and API. Caddy is the easiest way to add automatic SSL:
apt install caddy -yCreate the Caddyfile:
nano /etc/caddy/Caddyfile1mail.yourdomain.com {2 reverse_proxy localhost:30003}4
5dashboard.yourdomain.com {6 reverse_proxy localhost:30017}Start Caddy:
systemctl enable caddysystemctl start caddyCaddy automatically obtains Let's Encrypt certificates and handles renewal. Your API is now available at https://mail.yourdomain.com/v1 and your dashboard at https://dashboard.yourdomain.com.
Step 6: Configure authentication records
Open your dashboard at https://dashboard.yourdomain.com. On first login:
- Add your sending domain (
mail.yourdomain.com) - The dashboard shows you the exact DNS records to add:
- SPF: the
include:directive for your server - DKIM: two CNAME records with your public key
- DMARC: a starter
p=nonerecord
- SPF: the
Add them all to your DNS. Then click Verify in the dashboard. It will confirm each record is in place.
Step 7: Send your first email
Create an API key in the dashboard under Settings → API Keys.
Test with curl:
1curl -X POST https://mail.yourdomain.com/v1/emails \2 -H "Authorization: Bearer YOUR_API_KEY" \3 -H "Content-Type: application/json" \4 -d '{5 "from": "hello@yourdomain.com",6 "to": "your-personal-email@gmail.com",7 "subject": "Hello from my self-hosted Reloop!",8 "html": "<p>It works. 🎉</p>",9 "text": "It works."10 }'Check your inbox. If it's not there, check:
docker compose logs reloop-api: any errors?docker compose logs reloop-smtp: SMTP handshake issues?- DNS is propagated:
dig TXT yourdomain.comshows your SPF record?
A fresh server IP has no sending reputation yet. Ramp volume up over a few weeks with an IP warming schedule instead of sending your whole list on day one.
Step 8: Integrate with your application
The Reloop API is compatible with the Resend API shape. If you're migrating from Resend, it's usually a one-line change:
1// Before (Resend)2import { Resend } from "resend";3const client = new Resend(process.env.RESEND_API_KEY);4
5// After (Reloop, self-hosted)6import { Reloop } from "reloop-email";7const client = new Reloop(process.env.RELOOP_API_KEY, {8 baseUrl: "https://mail.yourdomain.com/v1",9});10
11// The send call is identical12await client.emails.send({13 from: "hello@yourdomain.com",14 to: "user@example.com",15 subject: "Welcome",16 html: "<p>Thanks for signing up.</p>",17});Ongoing maintenance
What needs attention
Updating Reloop
1cd /opt/reloop2git pull3docker compose pull4docker compose up -dRolling restart with zero downtime for the API. SMTP connections in flight will complete before the old container stops.
Monitoring disk usage
Email logs can grow fast. Set up a log rotation policy:
1# Check current disk usage2df -h3docker system df4
5# Clean up old logs6docker system prune --volumesConsider adding a monitoring alert when disk usage exceeds 80%.
Is self-hosting right for you?
Self-hosting is the right choice if:
- You send predictable, moderate volume (< 500k/month)
- You care about data sovereignty or have GDPR/compliance requirements
- You want to eliminate per-email pricing as you scale
- You have basic DevOps comfort (or someone on your team does)
A managed provider is better if:
- You need zero operational overhead
- You're sending at very high volume (millions/month) where infrastructure complexity is real
- You need guaranteed SLAs with financial backing
- Your team has no one comfortable maintaining a Linux server
For most early-stage and growing startups, self-hosting Reloop on a $4–6/month VPS is the highest-leverage infrastructure decision you can make. The cost savings compound and the control you gain is permanent.
Ship your first email with Reloop
in minutes.
Open-source, deliverability-focused, and yours to self-host or run on Reloop Cloud. No lock-in, no rewrite later.


