100 lines
3 KiB
Nix
100 lines
3 KiB
Nix
{ config, lib, pkgs, ... }:
|
|
let
|
|
postfixDir = "/var/spool/postfix";
|
|
in {
|
|
systemd.tmpfiles.rules = [
|
|
"d ${postfixDir} 0700 postfix postfix -"
|
|
];
|
|
services = let
|
|
sslCertDir = config.security.acme.certs."bogaledev.ru".directory;
|
|
in {
|
|
redis.servers.rspamd = {
|
|
enable = true;
|
|
user = "rspamd";
|
|
};
|
|
rspamd = {
|
|
enable = true;
|
|
postfix.enable = true;
|
|
locals."redis.conf".text = ''
|
|
servers = "${config.services.redis.servers.rspamd.unixSocket}";
|
|
'';
|
|
};
|
|
postfix = {
|
|
enable = true;
|
|
enableSubmissions = true;
|
|
virtualMapType = "regexp";
|
|
virtual = "/.*@bogaledev.ru/ mail@bogaledev.ru";
|
|
mapFiles.smtp_passwd = "/secrets/smtp_passwd";
|
|
settings.main = {
|
|
smtpd_sasl_type = "dovecot";
|
|
smtp_tls_wrappermode = true;
|
|
smtp_sasl_auth_enable = true;
|
|
smtpd_tls_wrappermode = true;
|
|
smtpd_sasl_auth_enable = true;
|
|
smtp_tls_security_level = "verify";
|
|
relayhost = [ "smtp.resend.com:2465" ];
|
|
smtpd_sasl_path = "${postfixDir}/auth";
|
|
virtual_mailbox_domains = "bogaledev.ru";
|
|
smtp_sasl_tls_security_options = "noanonymous";
|
|
smtp_sasl_password_maps = "hash:/etc/postfix/smtp_passwd";
|
|
virtual_transport = "lmtp:unix:${postfixDir}/dovecot-lmtp";
|
|
smtpd_tls_chain_files = [
|
|
"${sslCertDir}/key.pem"
|
|
"${sslCertDir}/fullchain.pem"
|
|
];
|
|
};
|
|
};
|
|
dovecot2 = {
|
|
enable = true;
|
|
settings = {
|
|
ssl = "required";
|
|
mail_gid = "vmail";
|
|
mail_uid = "vmail";
|
|
mail_driver = "maildir";
|
|
protocols = [ "imap" "lmtp" ];
|
|
auth_mechanisms = [ "plain" ];
|
|
dovecot_config_version = "2.4.5";
|
|
dovecot_storage_version = "2.4.5";
|
|
mail_path = "/var/spool/mail/vmail";
|
|
ssl_server_key_file = "${sslCertDir}/key.pem";
|
|
ssl_server_cert_file = "${sslCertDir}/fullchain.pem";
|
|
"passdb passwd-file".passwd_file_path = "/secrets/dovecot-pw";
|
|
"service auth"."unix_listener ${postfixDir}/auth" = {
|
|
mode = "0600";
|
|
user = "postfix";
|
|
group = "postfix";
|
|
};
|
|
"service lmtp"."unix_listener ${postfixDir}/dovecot-lmtp" = {
|
|
mode = "0600";
|
|
user = "postfix";
|
|
group = "postfix";
|
|
};
|
|
"namespace inbox" = {
|
|
inbox = true;
|
|
"mailbox Sent" = {
|
|
auto = "subscribe";
|
|
mailbox_special_use = "Sent";
|
|
};
|
|
"mailbox Archive" = {
|
|
auto = "create";
|
|
mailbox_special_use = "\\Archive";
|
|
};
|
|
"mailbox Important" = {
|
|
auto = "subscribe";
|
|
mailbox_special_use = "\\Flagged";
|
|
};
|
|
"mailbox Spam" = {
|
|
auto = "create";
|
|
mailbox_autoexpunge = "45d";
|
|
mailbox_special_use = "\\Junk";
|
|
};
|
|
"mailbox Trash" = {
|
|
auto = "create";
|
|
mailbox_autoexpunge = "45d";
|
|
mailbox_special_use = "\\Trash";
|
|
};
|
|
};
|
|
};
|
|
};
|
|
};
|
|
}
|