fix(mail): Got working stalwart mail config
This commit is contained in:
parent
e97003764a
commit
7927f6ca96
3 changed files with 56 additions and 25 deletions
|
@ -76,12 +76,12 @@ storage:
|
||||||
notifier:
|
notifier:
|
||||||
disable_startup_check: true
|
disable_startup_check: true
|
||||||
smtp:
|
smtp:
|
||||||
address: 'smtp://mail.gasdev.fr:25'
|
address: 'submissions://mail.gasdev.fr:465'
|
||||||
username: 'postmaster@gasdev.fr'
|
username: 'postmaster'
|
||||||
sender: 'Authelia <authelia@gasdev.fr>'
|
sender: 'Authelia <authelia@gasdev.fr>'
|
||||||
identifier: 'mail.gasdev.fr'
|
# identifier: 'mail.gasdev.fr'
|
||||||
tls:
|
# tls:
|
||||||
server_name: 'mail.gasdev.fr'
|
# server_name: 'mail.gasdev.fr'
|
||||||
|
|
||||||
log:
|
log:
|
||||||
level: 'info'
|
level: 'info'
|
||||||
|
|
|
@ -30,10 +30,10 @@
|
||||||
smtp = {
|
smtp = {
|
||||||
host = "mail.gasdev.fr";
|
host = "mail.gasdev.fr";
|
||||||
port = 465;
|
port = 465;
|
||||||
username = "postmaster@gasdev.fr";
|
username = "postmaster";
|
||||||
passwordFile = config.sops.secrets."outline/SMTP_PASSWORD".path;
|
passwordFile = config.sops.secrets."outline/SMTP_PASSWORD".path;
|
||||||
fromEmail = "from.outline@gasdev.fr";
|
fromEmail = "outline@gasdev.fr";
|
||||||
replyEmail = "reply.outline@gasdev.fr";
|
replyEmail = "no-reply@gasdev.fr";
|
||||||
};
|
};
|
||||||
|
|
||||||
storage = {
|
storage = {
|
||||||
|
|
|
@ -5,6 +5,11 @@ in {
|
||||||
sops.secrets."stalwart-mail/ACME_SECRET".owner = "stalwart-mail";
|
sops.secrets."stalwart-mail/ACME_SECRET".owner = "stalwart-mail";
|
||||||
|
|
||||||
services.caddy.virtualHosts."mailadmin.${domain}" = {
|
services.caddy.virtualHosts."mailadmin.${domain}" = {
|
||||||
|
extraConfig = ''
|
||||||
|
reverse_proxy http://127.0.01:40312
|
||||||
|
'';
|
||||||
|
};
|
||||||
|
services.caddy.virtualHosts."mail.${domain}" = {
|
||||||
extraConfig = ''
|
extraConfig = ''
|
||||||
reverse_proxy http://127.0.01:8080
|
reverse_proxy http://127.0.01:8080
|
||||||
'';
|
'';
|
||||||
|
@ -12,7 +17,7 @@ in {
|
||||||
"mta-sts.${domain}"
|
"mta-sts.${domain}"
|
||||||
"autoconfig.${domain}"
|
"autoconfig.${domain}"
|
||||||
"autodiscover.${domain}"
|
"autodiscover.${domain}"
|
||||||
"mail.${domain}"
|
"${domain}"
|
||||||
];
|
];
|
||||||
};
|
};
|
||||||
networking.firewall.allowedTCPPorts = [25 465 587 993];
|
networking.firewall.allowedTCPPorts = [25 465 587 993];
|
||||||
|
@ -21,7 +26,7 @@ in {
|
||||||
enable = true;
|
enable = true;
|
||||||
settings = {
|
settings = {
|
||||||
server = {
|
server = {
|
||||||
hostname = "mx1.${domain}";
|
hostname = "mail.${domain}";
|
||||||
tls = {
|
tls = {
|
||||||
enable = true;
|
enable = true;
|
||||||
implicit = true;
|
implicit = true;
|
||||||
|
@ -34,41 +39,36 @@ in {
|
||||||
submissions = {
|
submissions = {
|
||||||
bind = "[::]:465";
|
bind = "[::]:465";
|
||||||
protocol = "smtp";
|
protocol = "smtp";
|
||||||
|
tls.implicit = true;
|
||||||
};
|
};
|
||||||
imaps = {
|
imaps = {
|
||||||
bind = "[::]:993";
|
bind = "[::]:993";
|
||||||
protocol = "imap";
|
protocol = "imap";
|
||||||
|
tls.implicit = true;
|
||||||
};
|
};
|
||||||
jmap = {
|
jmap = {
|
||||||
bind = "[::]:8080";
|
bind = "[::]:8080";
|
||||||
url = "https://mail.${domain}";
|
protocol = "http";
|
||||||
protocol = "jmap";
|
tls.implicit = false;
|
||||||
};
|
};
|
||||||
management = {
|
management = {
|
||||||
bind = ["127.0.0.1:8080"];
|
bind = ["127.0.0.1:40312"];
|
||||||
protocol = "http";
|
protocol = "http";
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
lookup.default = {
|
lookup.default = {
|
||||||
hostname = "mx1.${domain}";
|
hostname = "mail.${domain}";
|
||||||
domain = "${domain}";
|
domain = "${domain}";
|
||||||
};
|
};
|
||||||
acme."letsencrypt" = {
|
certificate.default = {
|
||||||
default = true;
|
default = true;
|
||||||
directory = "https://acme-v02.api.letsencrypt.org/directory";
|
cert = "%{file:/var/lib/stalwart-mail/cert/mail.${domain}.pem}%";
|
||||||
challenge = "dns-01";
|
private-key = "%{file:/var/lib/stalwart-mail/cert/mail.${domain}.priv.pem}%";
|
||||||
contact = "postmaster@${domain}";
|
|
||||||
domains = ["${domain}" "mx1.${domain}"];
|
|
||||||
provider = "cloudflare";
|
|
||||||
secret = "%{file:${config.sops.secrets."stalwart-mail/ACME_SECRET".path}}%";
|
|
||||||
};
|
};
|
||||||
session.auth = {
|
session.auth = {
|
||||||
mechanisms = "[plain]";
|
mechanisms = "[plain, login]";
|
||||||
directory = "'in-memory'";
|
|
||||||
};
|
};
|
||||||
session.rcpt.directory = "'in-memory'";
|
|
||||||
queue.outbound.next-hop = "'local'";
|
|
||||||
directory."imap".lookup.domains = ["${domain}"];
|
directory."imap".lookup.domains = ["${domain}"];
|
||||||
storage = {
|
storage = {
|
||||||
data = "rocksdb";
|
data = "rocksdb";
|
||||||
|
@ -113,4 +113,35 @@ in {
|
||||||
StateDirectoryMode = "0740";
|
StateDirectoryMode = "0740";
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
|
|
||||||
|
systemd.timers."stalwart-mail-update-certs" = {
|
||||||
|
wantedBy = ["timers.target"];
|
||||||
|
timerConfig = {
|
||||||
|
OnCalendar = "daily";
|
||||||
|
Persistent = true;
|
||||||
|
Unit = "stalwart-mail-update-certs.service";
|
||||||
|
};
|
||||||
|
};
|
||||||
|
|
||||||
|
systemd.services."stalwart-mail-update-certs" = {
|
||||||
|
script = ''
|
||||||
|
set -eu
|
||||||
|
|
||||||
|
CADDY_CERT_DIR="/var/lib/caddy/.local/share/caddy/certificates/acme-v02.api.letsencrypt.org-directory/mail.${domain}"
|
||||||
|
STALWART_CERT_DIR="/var/lib/stalwart-mail/cert"
|
||||||
|
|
||||||
|
mkdir -p "''\${CADDY_CERT_DIR}"
|
||||||
|
mkdir -p "''\${STALWART_CERT_DIR}"
|
||||||
|
|
||||||
|
cat "''\${CADDY_CERT_DIR}/mail.${domain}.crt" > "''\${STALWART_CERT_DIR}/mail.${domain}.pem"
|
||||||
|
cat "''\${CADDY_CERT_DIR}/mail.${domain}.key" > "''\${STALWART_CERT_DIR}/mail.${domain}.priv.pem"
|
||||||
|
|
||||||
|
chown -R stalwart-mail:stalwart-mail "''\${STALWART_CERT_DIR}"
|
||||||
|
chmod -R 0700 "''\${STALWART_CERT_DIR}"
|
||||||
|
'';
|
||||||
|
serviceConfig = {
|
||||||
|
Type = "oneshot";
|
||||||
|
User = "root";
|
||||||
|
};
|
||||||
|
};
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue