all repos — nixfiles @ 21dbbf8b280beb2f3f2d8fa6cc38d3e8412f643a

System and user configuration, managed by nix and home-manager

system/roles/mailer.nix (view raw)

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
{
  config,
  ...
}:
let
  email = "alan@alanpearce.eu";
  domain = config.networking.domain;
  selector = 202603;
  # generate via `sudo -u rspamd rspamadm dkim_keygen -d $DOMAIN -s $SELECTOR -b 2048 -k /var/lib/rspamd/dkim/$SELECTOR.$DOMAIN.key -o dnskey`
in
{

  services.postfix = {
    enable = true;
    enableSubmission = true;
    submissionOptions = {
      smtpd_client_restrictions = "permit_inet_interfaces,reject";
      smtpd_tls_security_level = "none";
    };
    enableSubmissions = true;
    virtual = ''
      @${config.networking.hostName}.${domain} alin
      alin ${email}
    '';
    settings = {
      main = {
        mydomain = domain;
        mydestination = [ ];
        inet_interfaces = "loopback-only";
        smtp_bind_address = "0.0.0.0";
        smtp_bind_address6 = "::";
      };
    };
  };
  services.rspamd = {
    enable = true;
    postfix = {
      enable = true;
    };
    locals = {
      "outgoing.conf".text = ''
        outbound {
          priority = high;
          authenticated = yes;
          apply {
            groups_disabled = ["rbl", "spf", "dmarc"];
            actions {
              greylist = null;
            }
          }
        }
      '';
      "dkim_signing.conf".text = ''
        enabled = true;
        selector = "${toString selector}";
        domain = "${domain}";
        path = "/var/lib/rspamd/dkim/$selector.$domain.key";
      '';
    };
  };
}