Back to Home

Setting up a mail server in rural areas | Guide

Guide to setting up your own mail server under unstable internet conditions. Describes key stages: architecture selection, DNS setup, spam fighting, and security provision. Suitable for technical specialists.

Mail server in the village: how to avoid spam and failures
Advertisement 728x90

# Setting Up Your Own Mail Server in Rural Areas: A Practical Guide

Setting up your own mail server instead of using mass-market services is popular among those who value control over their data. However, in areas with unreliable internet and power supply—common in rural settings—the task becomes more challenging. This article walks through a step-by-step setup of a resilient system, covering architecture choices, critical DNS records, and methods to get past spam filters.

Architecture for Unreliable Networks: Why You Need a VPS

The classic setup of hosting a mail server on your home network doesn't work well in areas with frequent outages. When power or internet goes down, the server becomes unreachable, leading to lost incoming mail—external mail systems only retry delivery a few times before giving up.

The solution is a hybrid setup. The primary server runs on a VPS in a data center with guaranteed uptime. For family use, a config with 1-2 vCPU, 2-4 GB RAM, 40-60 GB SSD, and a clean IP is plenty. Debian is chosen as the OS due to its extensive documentation and support for mail solutions.

Google AdInline article slot

A home computer in the village serves as a backup: it handles data replication and local testing. If the main connection fails, incoming mail is temporarily buffered on the VPS, then synced to the home node once connectivity is restored. It's like how a post office works: if the village branch is closed, mail waits at the district center.

Critical DNS Records: The Foundation of Delivery

Proper DNS setup is key to reliability. For your domain (e.g., ded-v-derevne.ru), you need:

  • A record: Maps the domain to the VPS IP address.
  • MX record: Points to the server that accepts mail for the domain.
  • SPF record (TXT): Lists the IP addresses authorized to send mail on behalf of the domain.

Without SPF, mail gets flagged as spam since big services (Gmail, Outlook) check the sender's legitimacy. Example SPF record:

Google AdInline article slot
v=spf1 ip4:your_IP -all

This record allows sending only from the specified IPv4 address and blocks everything else.

Anti-Spam: DKIM and DMARC in Action

Even with SPF, mail can still hit spam folders without cryptographic signatures. DKIM solves this:

  • Generate keys on the server.
  • Publish the public key in DNS as a TXT record.
  • Configure the mail software to sign outgoing messages.

Example DKIM record in DNS:

Google AdInline article slot
default._domainkey IN TXT "v=DKIM1; k=rsa; p=public_key"

Additionally, set up DMARC—a policy for handling mail that fails SPF/DKIM checks. Minimal record:

_dmarc IN TXT "v=DMARC1; p=none; rua=mailto:your_email"

The p=none parameter means monitoring without blocking, which is safe during setup. After gathering stats (via rua), you can tighten it to p=quarantine or p=reject.

Resilience: Surviving Power Outages

Rural conditions demand protection from short outages. The main VPS in the data center handles connection stability, but the home part remains vulnerable. To minimize risks:

  • Automatic replication of mailboxes to the home computer via rsync over SSH.
  • Local mail caching enabled in the client (e.g., Thunderbird).
  • A Telegram bot for failure alerts, checking home server availability every 5 minutes.

When mobile internet comes back after an outage, the system auto-syncs new mail. External senders don't notice— their mail buffers on the VPS for 48 hours (standard retry period).

Security: Locking Down Unnecessary Ports

Running your own server expands your attack surface. A security audit was performed:

  • Scan open ports with nmap localhost.
  • Disable unneeded services (e.g., FTP, Telnet).
  • Restrict SSH access to trusted IPs via ufw.
  • Switch to SSH keys and use strong passwords for web interfaces.

Fail2ban is essential for blocking brute-force attacks. Config for Postfix:

[postfix]
enabled = true
maxretry = 3
bantime = 86400

This blocks an IP after three failed login attempts for 24 hours.

Key Takeaways

  • VPS is essential for stability: A home server can't handle frequent outages—use a hybrid setup.
  • DNS is the foundation: Without SPF, DKIM, and DMARC, mail ends up in spam even if the server works fine.
  • Security is non-negotiable: Close unused ports, use SSH keys, and run fail2ban.
  • Test with real services: Verify delivery to Gmail and Outlook before going live.

Running your own mail setup takes effort but gives full control and no ads in the interface. For small volumes (family, small team), it's a realistic alternative to big services. The key is to realistically assess limits: your server won't scale like Gmail, but it'll be a reliable tool for daily communication.

— Editorial Team

Advertisement 728x90

Read Next