summaryrefslogtreecommitdiff
path: root/hosts/cloud/hetzner/mail.nix
blob: 9ef4de8a5b49b914585f05434ed77653979988cc (plain)
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
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
{
  config,
  pkgs,
  ...
}: {
  environment.etc = {
    "stalwart/mail-pw1".text = "poguo";
    "stalwart/mail-pw2".text = "shahezai";
    "stalwart/admin-pw".text = "chengchun";
    "stalwart/acme-secret".text = "caomushen";
  };

  services.stalwart-mail = {
    enable = true;
    package = pkgs.stalwart-mail;
    openFirewall = true;
    settings = {
      server = {
        hostname = "mail.urbit.cloud";
        tls = {
          enable = true;
          implicit = true;
        };
        listener = {
          smtp = {
            protocol = "smtp";
            bind = "[::]:25";
          };
          submissions = {
            bind = "[::]:465";
            protocol = "smtp";
          };
          imaps = {
            bind = "[::]:993";
            protocol = "imap";
          };
          jmap = {
            bind = "[::]:8888";
            url = "https://mail.urbit.cloud";
            protocol = "jmap";
          };
          management = {
            bind = ["127.0.0.1:8888"];
            protocol = "http";
          };
        };
      };
      lookup.default = {
        hostname = "mail.urbit.cloud";
        domain = "urbit.cloud";
      };
      session.auth = {
        mechanisms = "[plain]";
        directory = "'in-memory'";
      };
      storage.directory = "in-memory";
      session.rcpt.directory = "'in-memory'";
      queue.outbound.next-hop = "'local'";
      directory."in-memory" = {
        type = "memory";
        principals = [
          {
            class = "individual";
            name = "polwex";
            secret = "%{file:/etc/stalwart/mail-pw1}%";
            email = ["polwex@urbit.cloud"];
          }
          {
            class = "individual";
            name = "postmaster";
            secret = "%{file:/etc/stalwart/mail-pw1}%";
            email = ["postmaster@urbit.cloud"];
          }
        ];
      };
      authentication.fallback-admin = {
        user = "admin";
        secret = "%{file:/etc/stalwart/admin-pw}%";
      };
    };
  };
}