2024-11-05 14:39:49 +01:00
|
|
|
{config, ...}: let
|
2024-11-05 18:35:52 +01:00
|
|
|
domain = "gasdev.fr";
|
2024-11-05 14:39:49 +01:00
|
|
|
in {
|
|
|
|
sops.secrets."stalwart-mail/ADMIN_SECRET".owner = "stalwart-mail";
|
2024-11-10 19:52:04 +01:00
|
|
|
sops.secrets."stalwart-mail/ACME_SECRET".owner = "stalwart-mail";
|
2024-11-05 14:39:49 +01:00
|
|
|
|
2024-11-10 19:52:04 +01:00
|
|
|
services.caddy.virtualHosts."mailadmin.${domain}" = {
|
|
|
|
extraConfig = ''
|
|
|
|
reverse_proxy http://127.0.01:8080
|
|
|
|
'';
|
|
|
|
serverAliases = [
|
|
|
|
"mta-sts.${domain}"
|
|
|
|
"autoconfig.${domain}"
|
|
|
|
"autodiscover.${domain}"
|
|
|
|
"mail.${domain}"
|
|
|
|
];
|
|
|
|
};
|
|
|
|
networking.firewall.allowedTCPPorts = [25 465 587 993];
|
2024-11-05 14:39:49 +01:00
|
|
|
|
|
|
|
services.stalwart-mail = {
|
|
|
|
enable = true;
|
|
|
|
settings = {
|
|
|
|
server = {
|
2024-11-10 19:52:04 +01:00
|
|
|
hostname = "mx1.${domain}";
|
|
|
|
tls = {
|
|
|
|
enable = true;
|
|
|
|
implicit = true;
|
2024-11-05 14:39:49 +01:00
|
|
|
};
|
|
|
|
listener = {
|
|
|
|
smtp = {
|
|
|
|
protocol = "smtp";
|
2024-11-10 19:52:04 +01:00
|
|
|
bind = "[::]:25";
|
2024-11-05 14:39:49 +01:00
|
|
|
};
|
|
|
|
submissions = {
|
2024-11-10 19:52:04 +01:00
|
|
|
bind = "[::]:465";
|
2024-11-05 14:39:49 +01:00
|
|
|
protocol = "smtp";
|
|
|
|
};
|
2024-11-10 19:52:04 +01:00
|
|
|
imaps = {
|
|
|
|
bind = "[::]:993";
|
2024-11-05 14:39:49 +01:00
|
|
|
protocol = "imap";
|
|
|
|
};
|
2024-11-10 19:52:04 +01:00
|
|
|
jmap = {
|
2024-11-05 14:39:49 +01:00
|
|
|
bind = "[::]:8080";
|
2024-11-10 19:52:04 +01:00
|
|
|
url = "https://mail.${domain}";
|
|
|
|
protocol = "jmap";
|
|
|
|
};
|
|
|
|
management = {
|
|
|
|
bind = ["127.0.0.1:8080"];
|
2024-11-05 14:39:49 +01:00
|
|
|
protocol = "http";
|
|
|
|
};
|
|
|
|
};
|
|
|
|
};
|
2024-11-10 19:52:04 +01:00
|
|
|
lookup.default = {
|
|
|
|
hostname = "mx1.${domain}";
|
|
|
|
domain = "${domain}";
|
2024-11-05 14:39:49 +01:00
|
|
|
};
|
2024-11-10 19:52:04 +01:00
|
|
|
acme."letsencrypt" = {
|
|
|
|
directory = "https://acme-v02.api.letsencrypt.org/directory";
|
|
|
|
challenge = "dns-01";
|
|
|
|
contact = "postmaster@${domain}";
|
|
|
|
domains = ["${domain}" "mx1.${domain}"];
|
|
|
|
provider = "cloudflare";
|
|
|
|
secret = "%{file:${config.sops.secrets."stalwart-mail/ACME_SECRET".path}}%";
|
|
|
|
};
|
|
|
|
session.auth = {
|
|
|
|
mechanisms = "[plain]";
|
|
|
|
directory = "'in-memory'";
|
|
|
|
};
|
|
|
|
session.rcpt.directory = "'in-memory'";
|
|
|
|
queue.outbound.next-hop = "'local'";
|
|
|
|
directory."imap".lookup.domains = ["${domain}"];
|
2024-11-05 14:39:49 +01:00
|
|
|
storage = {
|
|
|
|
data = "rocksdb";
|
|
|
|
fts = "rocksdb";
|
|
|
|
blob = "rocksdb";
|
|
|
|
lookup = "rocksdb";
|
|
|
|
directory = "internal";
|
|
|
|
};
|
|
|
|
store."rocksdb" = {
|
|
|
|
type = "rocksdb";
|
|
|
|
path = "%{env:STALWART_PATH}%/data";
|
|
|
|
compression = "lz4";
|
|
|
|
};
|
|
|
|
directory."internal" = {
|
|
|
|
type = "internal";
|
|
|
|
store = "rocksdb";
|
|
|
|
};
|
|
|
|
tracer."stdout" = {
|
|
|
|
type = "stdout";
|
|
|
|
level = "info";
|
|
|
|
ansi = false;
|
|
|
|
enable = true;
|
|
|
|
};
|
|
|
|
authentication."fallback-admin" = {
|
|
|
|
user = "admin";
|
|
|
|
secret = "%{file:${config.sops.secrets."stalwart-mail/ADMIN_SECRET".path}}%";
|
|
|
|
};
|
|
|
|
};
|
|
|
|
};
|
|
|
|
|
|
|
|
systemd.services.stalwart-mail = {
|
|
|
|
environment = {
|
|
|
|
STALWART_PATH = "/var/lib/stalwart-mail";
|
|
|
|
};
|
|
|
|
serviceConfig = {
|
|
|
|
StateDirectory = "stalwart-mail";
|
|
|
|
StateDirectoryMode = "0740";
|
|
|
|
};
|
|
|
|
};
|
|
|
|
}
|