Mail server
A mail server that runs on NanumOS itself: it receives mail for your own domain, keeps it in your mailboxes, lets a mail program read it, and sends your people's mail on to other mail servers. It is tested in closed test networks against well-known mail servers; using it for real mail on the internet needs a few settings of your own first (see the questions below).
What it is
Like a post office with a counter and a letter box for every person. The counter takes in letters for the addresses it serves and turns away everything else; the letter box is where you read yours with any mail program. The post office also has a van: letters your people hand in for other towns are driven to the post office of that town, and if it is closed the van tries again later.
What to do now: nothing, unless you are trying it out. In a test setup, follow the steps below.
How to use it
- Write the settings — a file
/etc/mailsrv.confwith at leastdomain=example.testandhostname=mx.example.test. A server without a domain does not start. - Check —
fetch --mailsrvd checkreads the settings and keys and says what would run. To sign outgoing mail,fetch --mailsrvd dkim-keygen /var/lib/mailsrv/dkim.pemmakes a key and prints the one line to publish in your domain's DNS; then adddkim=example.test:mail:/var/lib/mailsrv/dkim.pemto the settings. - Start — as a service (
service mail start, see the technical details) or by hand:fetch --mailsrvd run. - Read mail — point a mail program at the server's IMAP port (143). Passwords are accepted only over an encrypted connection (STARTTLS on 143, or IMAPS on 993) once a certificate folder is set (
tls_dir); a test setup without one has to sayallow_plain=1, and Settings says so while it is on.
In Settings › Diagnostics the row 「메일 서버」 (mail server) shows the ports, how many letters wait in the queue and when the server last reported.
How it works
- A letter arrives at port 25. The server asks first: is the address one of ours, and does that person exist? If not it says no right away — it never passes mail on for strangers.
- The letter is written to disk and the disk is told to keep it before the server answers 「accepted」. If the power goes out one second later, the letter is still there at the next start and is delivered exactly once.
- Then the checks run: does the sending computer have the right to send for that domain (SPF), is the letter signed and unchanged (DKIM), and what does the domain say to do with a letter that fails (DMARC). The result is written at the top of the letter. A failing letter goes to the Junk folder, or, when the domain asks for it, is set aside and never delivered.
- Mail from your own people goes in through port 587, with a password, and is signed with your domain's key. A letter for another domain is then sent on:
- Find the other post office. The server asks DNS which mail servers take mail for that domain (MX), in the order the domain prefers.
- Knock and speak. It connects, switches to an encrypted connection whenever the other side offers one, and hands the letter over.
- Write down the answer at once. For each recipient the answer (「accepted」, 「try later」 or 「no」) is written to disk the moment it arrives, before anything else happens. So after a crash or power cut no recipient gets the letter twice and none is forgotten.
- Try again, then tell you. 「Try later」 is tried again after 5 minutes, then 10, 20 ... up to every 4 hours. If it still has not gone after 5 days, or the other side says 「no」, you get one report in your INBOX that says which address failed and what the other server answered.
- Only your own signed-in people can send to other domains. Port 25 never passes mail on for strangers, and a report never goes to a stranger.
- The mail program reads through IMAP: folders, search, flags, moving, drafts, and a notification when new mail arrives.
What this takes
- Takes: only what a mail server must keep — each person's mail, their password in a scrambled form (never the password itself), and a short log of who connected and what was accepted or refused.
- Does not take: nothing is sent to us. Mail goes only where your people address it. The block list lookup is off unless you turn it on; it would send the sender's address to the list you choose.
- Where it goes:
/var/lib/mailsrvon this device (mail, queue, users); DNS questions (the sender's SPF, DKIM and DMARC records; the MX of a domain you send to) to the DNS server of the network; and a letter your person sends to another domain goes to that domain's mail server, nowhere else. - How long: until you delete it; failed deliveries stay in
queue/failedfor you to look at; set-aside letters inrejectedtoo. - How to turn it off:
service mail stopand remove themailservice file; delete/var/lib/mailsrvto remove all mail.
Technical details
- Command:
fetch --mailsrvd [-c CONF] run|useradd ADDR|check|queue|dkim-keygen KEYFILE [BITS]. In a build withoutMAILSRV=1the command says it is not in this build. -m 256gives the server room for big letters (a NanumOS program has 16 MB unless it asks); without it a big letter waits in the queue instead of going out.- Ports: SMTP 25, submission 587, IMAP 143 (set any to 0 to turn it off). With
tls_dirset: STARTTLS on 25/587/143 and IMAPS on 993. - Limits: 25 MB a letter, 100 recipients, 10 errors a session, 64 connections, 8 per address, 5 wrong passwords in 10 minutes lock an address out for a while.
- Sending (settings, defaults in brackets):
outbound(1; 0 = refuse other domains),out_conn(20 connections),out_conn_domain(5 per domain),out_rate_domain(600 new letters a minute per domain),retry_base(300 s),retry_max(4 h),queue_lifetime(5 days),out_tls/out_tls_domain=DOMAIN:may|encrypt|none(may: encrypt when offered; encrypt: never send that domain anything unencrypted). - Encryption when sending is TLS 1.2 and opportunistic (the other server's certificate is not checked, as mail servers do without MTA-STS or DANE; those come later).
- Per-recipient answers:
queue/new/<id>.s; the state file countsout_sent,out_deferred,out_failed,out_dsn. - Files:
/var/lib/mailsrv/users,mail/<user>/{new,cur,tmp}(Maildir),queue/,rejected/,state. - Contract and tests:
docs/contracts/MAILSRV.md,tests/test_mailsrv.py,tests/test_mailsrv_out.py, and the lab with real mail servers (Postfix, maddy)tests/mailsrv_e2e.py.
Common questions
- Can I send mail to other people with it? Yes: sign in on port 587 and send to any address. For big providers (Gmail, Naver) to put it in the inbox rather than refuse it or file it as spam, the server needs a fixed public address that may send mail, a matching reverse name (PTR), and SPF, DKIM and DMARC records in your domain. Home internet lines usually cannot send mail that is trusted.
- Someone did not get my letter. Look in your INBOX for a report 「보내지 못한 메일 / Undelivered mail」: it names the address and quotes the other server's answer. No report yet means the server is still trying (up to 5 days).
- Could a letter go out twice? Only in one moment SMTP itself cannot close: if the server dies exactly after handing over the end of a letter and before the other side says 「accepted」. Then it sends it again — twice rather than never.
- Why will my mail program not log in? The server refuses passwords on an unencrypted connection. Set
tls_dirto a folder with your certificate (the web server's certificate folder works), or in a test setupallow_plain=1. - A letter I expected is in Junk. Open its headers:
Authentication-ResultsandX-Spam-Scoresay which check it failed. - The server was killed in the middle of receiving. A letter that was not answered 「accepted」 is sent again by the sender; one that was answered is on disk and arrives.
- Korean addresses and subjects? Work: Korean names in addresses (SMTPUTF8), subjects, text, file names and folder names are stored and returned exactly as sent.
NanumOS 0.1.8349 · 2026-11-16