A settlement mail server needs two programs: an SMTP server such as Postfix to accept and route mail, and an IMAP server such as Dovecot to let people read it, with each person’s mail kept as one file per message in a directory. The server must accept mail only for its own domain and relay only for machines on the settlement’s own networks, and mail for another settlement is found through the DNS mail record and queued if the link is down. Plan the disk: with the example figures below, 100 users receiving 50 messages a day of 20 kB each fill about 36.5 GB a year.
Part of Networking
Running email for a settlement: the two servers, the DNS records that route mail, account and relay settings, and mail between settlements.
Email Inside A Settlement Needs No Outside World
Messaging explains the model: the sender hands the message to a server by SMTP, that server delivers it to the recipient’s server by SMTP, and the recipient reads it by IMAP or POP3, with IMAP preferred because messages stay on the server and every device sees the same mailbox. It also describes the maildir layout, a directory per user with one file per message, and notes that the authentication layers added to SMTP (DKIM, SPF and DMARC) were a response to abuse by spammers. The carrier Internet Infrastructure gives the recipe: Postfix for SMTP, Dovecot for IMAP, an account per community member, the domain set to the settlement’s own, and Roundcube as an optional webmail.
On a closed network the open-internet problems do not exist, and neither do the rules that responded to them: nobody outside can send you spam, and there is no one to impress with a sender signature. What does remain is relay control and the hardware.
What You Need
- A server with a fixed address and a name (Linux Server Setup, DNS)
- An MX record pointing the domain at the server (DNS Records)
- Postfix and Dovecot and their documentation, in the offline archive
- A list of accounts
- Disk space with a quota per user (Shared Resources)
Method: Bring Up Settlement Mail
Step 1: Set the domain and the MX record For example @settlement.internal, with an MX record naming mail.settlement.internal. SMTP between servers uses port 25 and name lookup finds the target (Core Protocols).
Step 2: Store mail one file per message Use the maildir layout so a damaged file loses one message, not a mailbox.
Step 3: Restrict relaying to your own networks Postfix has a setting that lists the networks whose machines may send mail through it (mynetworks, general knowledge). Set it to the settlement’s address blocks and nothing else. Without that limit, any machine that reaches the server can use it to send to anyone.
Step 4: Create the accounts and give each a quota One per person; remove accounts when people leave (Access Control).
Step 5: Send a test from one account to another, then between machines Read the server’s mail log if it does not arrive.
Step 6: Connect other settlements Give each settlement its own mail domain and server, with an MX record for each in the shared name zones (DNS Hierarchy). A message to another settlement is delivered by SMTP across the routed link. If the link is down, the sending server keeps the message in its queue and tries again (general knowledge), so mail survives short outages.
Step 7: Back up the mail directories Mail is data: copy it to a second machine like any other (File Transfer).
Worked Example: A Message’s Path And A Year’s Disk
The path. alice@north.region.internal writes to bob@south.region.internal. (1) North’s server asks DNS for the MX record of south.region.internal and gets mail.south.region.internal. (2) It asks for that name’s address. (3) It opens a TCP connection to that address on port 25 and passes the message. (4) South’s server writes the message as a file in Bob’s mail directory. (5) Bob’s mail program asks South’s server for his mail by IMAP.
The disk. These inputs are invented to show the arithmetic: 100 users, 50 messages each per day, 20 kB per message. Per day: 100 x 50 = 5,000 messages; 5,000 x 20 kB = 100,000 kB = 100 MB. Per year: 100 MB x 365 = 36,500 MB = 36.5 GB. Because IMAP keeps mail on the server (Messaging), the disk grows by this much unless users delete mail, and attachments can easily outweigh the text, so quotas matter.
Common Mistakes
- An open relay — the server sends mail for anyone who can reach it; limit the trusted networks
- An MX record that points at an address — it must name a host (DNS Records)
- One mail server with no backup — a disk failure deletes everyone’s correspondence
- Reading the queue never — a message stuck in the queue because a name does not resolve is the usual cause of “my mail disappeared”
What’s Next
- Learn next: File Sharing — the other service people use every day
- Combine with: Encryption Basics — protecting mail passwords on a shared network