Full-featured mail server via simple-nixos-mailserver.
Handles inbound and outbound mail for yhkze.net with DKIM
signing, SPF, DMARC, and Sieve filtering.
FQDN: mail.yhkze.net (DNS only — reference Cloudflare DNS)
Module: modules/features/mailserver.nix
| Account | Aliases | Purpose |
|---|---|---|
[email protected] |
personal@, self@ |
Personal |
[email protected] |
programming@, dev@ |
Programming / development |
[email protected] |
academia@, edu@ |
Academia |
[email protected] |
professional@, work@ |
Professional |
[email protected] |
— | Art |
[email protected] |
gaming@, entertainment@ |
Entertainment |
[email protected] |
invoice@, billing@ |
Invoicing |
[email protected] |
services@, automation@ |
Service accounts / automation |
[email protected] |
catch-all | Catch-all for anything else |
All passwords are SOPS-managed under
mail/users/<account>.
After initial deploy, DKIM keys are generated at
/var/dkim/. Add the public key as a TXT record in
Cloudflare:
# On server — get the DKIM public key
cat /var/dkim/yhkze.net.mail.txtAdd the output as a TXT record in Cloudflare DNS with name
mail._domainkey.yhkze.net.
SPF (v=spf1 mx include:spf.smtp2go.com ~all) and DMARC
are already configured — reference Cloudflare
DNS.
Outbound mail is relayed through SMTP2GO — the server has no public IP, so providers like Gmail distrust direct delivery. The free tier covers 1,000 emails/month across all accounts.
Postfix authenticates to [mail.smtp2go.com]:2525 with
mandatory TLS. SNM pins smtp_tls_security_level = dane,
which degrades to opportunistic TLS when the relay publishes no TLSA
records — the module forces encrypt instead. Credentials
are SOPS-managed under mail/relay/sasl and compiled into a
Postfix map at service start, so nothing lands world-readable in
main.cf. Local delivery is unaffected:
relayhost applies only to non-local domains.
SPF/DKIM/DMARC: SMTP2GO signs with d=yhkze.net via its
CNAME records, and the local OpenDKIM signature
(mail._domainkey) is added on top — both aligned.
SPF is evaluated against the envelope sender, not the
From: header. SMTP2GO rewrites the return path to
em962084.yhkze.net, which CNAMEs to
return.smtp2go.net and inherits
v=spf1 include:spf.smtp2go.com ~all, so relayed mail passes
on that subdomain — and passes DMARC alignment too, since relaxed
alignment matches on the organizational domain.
The root record nevertheless carries
include:spf.smtp2go.com as well. That covers the case where
the return path is not rewritten and the envelope sender stays
@yhkze.net, which would otherwise leave DMARC resting on
DKIM alone. It costs one DNS lookup. Reference Cloudflare DNS.
Sending > SMTP Users,
password stored in KeePassXCyhkze.net verified via 3 CNAME
recordsGenerate a new password, store it in KeePassXC, then update the vault:
cd hosts/server && sops secrets/secrets.yamlThe entry must be nested maps under mail: — keys
containing / are unreachable by sops-nix:
mail:
relay:
sasl: "[mail.smtp2go.com]:2525 <username>:<password>"The secret change restarts postfix.service
automatically.
Add entry to accounts in
modules/features/mailserver.nix
Add corresponding SOPS secret under
mail/users/<account>
Generate a random password (store it in KeePassXC), then hash it:
mkpasswd -m sha-512Store the hash in SOPS, deploy:
rebuild 10.100.0.1| Setting | Value |
|---|---|
| IMAP server | mail.yhkze.net |
| IMAP port | 993 (SSL/TLS) |
| SMTP server | mail.yhkze.net |
| SMTP port | 465 (SSL/TLS) or 587 (STARTTLS) |
| Username | Full email address |
| Password | Account password |
Check mail queue:
sudo postqueue -pForce queue flush:
sudo postqueue -fCheck logs:
journalctl -u postfix -n 50
journalctl -u dovecot2 -n 50Test DKIM signing:
sudo opendkim-testkey -d yhkze.net -s mail -vvv