From 1f70d58853bd87bf0d4fccfd0d32c7fb01af3eaf Mon Sep 17 00:00:00 2001 From: Rouven Seifert Date: Fri, 25 Nov 2022 15:24:05 +0100 Subject: [PATCH] Initial Email config Bare-minimum config consisting of postfix and dovecot2. For testing, passwd is used as userdb. Definitely NOT Production ready! --- modules/mail.nix | 69 ++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 69 insertions(+) create mode 100644 modules/mail.nix diff --git a/modules/mail.nix b/modules/mail.nix new file mode 100644 index 0000000..078a4fb --- /dev/null +++ b/modules/mail.nix @@ -0,0 +1,69 @@ +{ config, pkgs, ... }: + let hostname = "mail.test.stramke.com"; + in { + networking.firewall.allowedTCPPorts = [ 25 587 143]; + services = { + postfix = { + enable = true; + hostname = "${hostname}"; + config = { + myorigin = "mail.test.stramke.com"; + mydestination = "127.0.0.1"; + smtpd_recipient_restrictions = [ + "reject_unauth_destination" + "permit_sasl_authenticated" + + ]; + smtpd_sasl_auth_enable = true; + smtpd_sasl_path = "/var/lib/postfix/auth"; + smtpd_sasl_type = "dovecot"; + smtpd_relay_restrictions = [ + "reject_unauth_destination" + # "relay_domains = "${hostname}" + "permit_sasl_authenticated" + ]; + }; + }; + dovecot2 = { + enable = true; + enableImap = true; + enableQuota = false; + mailboxes = { + Spam = { + auto = "create"; + specialUse = "Junk"; + }; + Sent = { + auto = "create"; + specialUse = "Sent"; + }; + Drafts = { + auto = "create"; + specialUse = "Drafts"; + }; + Trash = { + auto = "create"; + specialUse = "Trash"; + }; + }; + extraConfig = '' + mail_location = mbox:~/mail:INBOX=/var/mail/%u + # auth_mechanisms = plain login + # disable_plaintext_auth = no + userdb { + driver = passwd + args = blocking=no + } + service auth { + unix_listener /var/lib/postfix/auth { + group = postfix + mode = 0660 + user = postfix + } + user = dovecot2 + } + ''; + }; + }; + } +