DEV Community

Dhiraj Chatpar
Dhiraj Chatpar

Posted on • Originally published at postmta.com

Setting Up a Production Mail Server on Ubuntu in 30 Minutes

Setting Up a Production Mail Server on Ubuntu in 30 Minutes

Most tutorials for setting up a mail server result in emails landing in spam. This guide covers exactly what it takes to get a production-grade mail server running that actually delivers.

Why 30 Minutes Is Not Enough

A basic Postfix setup takes 30 minutes. A production setup that actually delivers to Gmail inbox takes longer because:

  • Proper DNS records (SPF, DKIM, DMARC) take time to propagate
  • IP warmup cannot be rushed
  • Feedback loop setup requires ISP registration

This guide covers the 30-minute setup. Warmup is a separate 8-week process.

Prerequisites

  • Ubuntu 22.04 VPS with 2GB RAM minimum
  • Domain name with DNS access
  • Dedicated IP address (not shared)
  • Port 25 open (many VPS providers block this)

Install KumoMTA

curl -1sLf \
  'https://repo.kumomta.com/gpg.67E7103C/key' | sudo gpg --dearmor -o /usr/share/keyrings/kumomta-archive-keyring.gpg

echo "deb [signed-by=/usr/share/keyrings/kumomta-archive-keyring.gpg] https://repo.kumomta.com/ubuntu/ $(lsb_release -cs) main" \
  | sudo tee /etc/apt/sources.list.d/kumomta.list

sudo apt update && sudo apt install kumomta
Enter fullscreen mode Exit fullscreen mode

Configure DNS Records

Before sending anything, set up authentication:

SPF Record:

v=spf1 ip4:YOUR_SERVER_IP -all
Enter fullscreen mode Exit fullscreen mode

DKIM Record:
KumoMTA generates keys automatically. Add the public key to DNS with selector mail.

DMARC Record:

_dmarc.yourdomain.com TXT "v=DMARC1; p=none; rua=mailto:dmarc@yourdomain.com"
Enter fullscreen mode Exit fullscreen mode

Configure KumoMTA

sudo nano /etc/kumomta/kumo-mta.conf
Enter fullscreen mode Exit fullscreen mode

Basic configuration for single domain:

listen 0.0.0.0:2525 {
  relay_hosts ["0.0.0.0/0"]
  smtpanner_enabled true
}

dkim_sign {
  domain 'yourdomain.com'
  selector 'mail'
  path '/var/db/kumomta/dkim/'
}

queue_run {
  throttle '100/second'
}
Enter fullscreen mode Exit fullscreen mode

Start and Test

sudo systemctl enable kumomta
sudo systemctl start kumomta

# Test injection
curl -X POST http://localhost:2525/inject \
  -d "mail_from=test@yourdomain.com" \
  -d "rcpt_to=test@gmail.com" \
  -d "message=From: test@yourdomain.com\\nTo: test@gmail.com\\nSubject: Test\\n\\nTest body"
Enter fullscreen mode Exit fullscreen mode

Verify Authentication

Before sending real email:

  • Check SPF: dig +short TXT yourdomain.com
  • Check DKIM: dig +short TXT mail._domainkey.yourdomain.com
  • Check DMARC: dig +short TXT _dmarc.yourdomain.com
  • Test with GlockApps before major campaigns

The Warmup Phase

After setup, you MUST warm up:

  • Day 1-7: 100-200 emails/day to highly engaged recipients
  • Week 2: 500/day
  • Week 3: 1,000/day
  • Continue ramping until at target volume

PostMTA offers managed KumoMTA setup and warmup as a service. Starting at $200/month.

Top comments (0)