2016-07-25 20:48:40 +05:00
|
|
|
# nixos-mailserver: a simple mail server
|
2018-01-29 14:34:27 +05:00
|
|
|
# Copyright (C) 2016-2018 Robin Raymond
|
2016-07-25 20:48:40 +05:00
|
|
|
#
|
|
|
|
# This program is free software: you can redistribute it and/or modify
|
|
|
|
# it under the terms of the GNU General Public License as published by
|
|
|
|
# the Free Software Foundation, either version 3 of the License, or
|
|
|
|
# (at your option) any later version.
|
|
|
|
#
|
|
|
|
# This program is distributed in the hope that it will be useful,
|
|
|
|
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
# GNU General Public License for more details.
|
|
|
|
#
|
|
|
|
# You should have received a copy of the GNU General Public License
|
|
|
|
# along with this program. If not, see <http://www.gnu.org/licenses/>
|
|
|
|
|
2017-09-03 14:13:34 +05:00
|
|
|
{ config, pkgs, lib, ... }:
|
|
|
|
|
2020-03-06 22:27:47 +05:00
|
|
|
with (import ./common.nix { inherit config pkgs lib; });
|
2017-08-12 14:27:19 +05:00
|
|
|
|
2017-08-12 19:14:16 +05:00
|
|
|
let
|
2017-11-10 02:13:27 +05:00
|
|
|
inherit (lib.strings) concatStringsSep;
|
2017-09-03 14:13:34 +05:00
|
|
|
cfg = config.mailserver;
|
|
|
|
|
2021-01-29 03:58:08 +05:00
|
|
|
# Merge several lookup tables. A lookup table is a attribute set where
|
|
|
|
# - the key is an address (user@example.com) or a domain (@example.com)
|
|
|
|
# - the value is a list of addresses
|
|
|
|
mergeLookupTables = tables: lib.zipAttrsWith (n: v: lib.flatten v) tables;
|
|
|
|
|
|
|
|
# valiases_postfix :: Map String [String]
|
|
|
|
valiases_postfix = mergeLookupTables (lib.flatten (lib.mapAttrsToList
|
2017-11-21 15:18:07 +05:00
|
|
|
(name: value:
|
|
|
|
let to = name;
|
2021-01-29 03:58:08 +05:00
|
|
|
in map (from: {"${from}" = to;}) (value.aliases ++ lib.singleton name))
|
|
|
|
cfg.loginAccounts));
|
2023-07-13 21:49:31 +05:00
|
|
|
regex_valiases_postfix = mergeLookupTables (lib.flatten (lib.mapAttrsToList
|
|
|
|
(name: value:
|
|
|
|
let to = name;
|
|
|
|
in map (from: {"${from}" = to;}) value.aliasesRegexp)
|
|
|
|
cfg.loginAccounts));
|
2017-11-21 15:18:07 +05:00
|
|
|
|
2021-01-29 03:58:08 +05:00
|
|
|
# catchAllPostfix :: Map String [String]
|
|
|
|
catchAllPostfix = mergeLookupTables (lib.flatten (lib.mapAttrsToList
|
2017-12-18 16:26:54 +05:00
|
|
|
(name: value:
|
|
|
|
let to = name;
|
2021-01-29 03:58:08 +05:00
|
|
|
in map (from: {"@${from}" = to;}) value.catchAll)
|
|
|
|
cfg.loginAccounts));
|
|
|
|
|
|
|
|
# all_valiases_postfix :: Map String [String]
|
|
|
|
all_valiases_postfix = mergeLookupTables [valiases_postfix extra_valiases_postfix];
|
|
|
|
|
|
|
|
# attrsToLookupTable :: Map String (Either String [ String ]) -> Map String [String]
|
|
|
|
attrsToLookupTable = aliases: let
|
|
|
|
lookupTables = lib.mapAttrsToList (from: to: {"${from}" = to;}) aliases;
|
|
|
|
in mergeLookupTables lookupTables;
|
2017-12-18 16:26:54 +05:00
|
|
|
|
2021-01-29 03:58:08 +05:00
|
|
|
# extra_valiases_postfix :: Map String [String]
|
|
|
|
extra_valiases_postfix = attrsToLookupTable cfg.extraVirtualAliases;
|
2017-08-12 19:14:16 +05:00
|
|
|
|
2021-01-29 03:58:08 +05:00
|
|
|
# forwards :: Map String [String]
|
|
|
|
forwards = attrsToLookupTable cfg.forwards;
|
|
|
|
|
|
|
|
# lookupTableToString :: Map String [String] -> String
|
|
|
|
lookupTableToString = attrs: let
|
|
|
|
valueToString = value: lib.concatStringsSep ", " value;
|
|
|
|
in lib.concatStringsSep "\n" (lib.mapAttrsToList (name: value: "${name} ${valueToString value}") attrs);
|
|
|
|
|
|
|
|
# valiases_file :: Path
|
|
|
|
valiases_file = let
|
|
|
|
content = lookupTableToString (mergeLookupTables [all_valiases_postfix catchAllPostfix]);
|
|
|
|
in builtins.toFile "valias" content;
|
2017-11-21 15:18:07 +05:00
|
|
|
|
2023-07-13 21:49:31 +05:00
|
|
|
regex_valiases_file = let
|
|
|
|
content = lookupTableToString regex_valiases_postfix;
|
|
|
|
in builtins.toFile "regex_valias" content;
|
|
|
|
|
2019-10-17 00:51:45 +05:00
|
|
|
# denied_recipients_postfix :: [ String ]
|
|
|
|
denied_recipients_postfix = (map
|
2020-04-26 02:33:01 +05:00
|
|
|
(acct: "${acct.name} REJECT ${acct.sendOnlyRejectMessage}")
|
2019-10-17 00:51:45 +05:00
|
|
|
(lib.filter (acct: acct.sendOnly) (lib.attrValues cfg.loginAccounts)));
|
|
|
|
denied_recipients_file = builtins.toFile "denied_recipients" (lib.concatStringsSep "\n" denied_recipients_postfix);
|
|
|
|
|
2018-11-10 18:29:16 +05:00
|
|
|
reject_senders_postfix = (map
|
|
|
|
(sender:
|
|
|
|
"${sender} REJECT")
|
|
|
|
(cfg.rejectSender));
|
|
|
|
reject_senders_file = builtins.toFile "reject_senders" (lib.concatStringsSep "\n" (reject_senders_postfix)) ;
|
|
|
|
|
2018-04-15 04:37:30 +05:00
|
|
|
reject_recipients_postfix = (map
|
|
|
|
(recipient:
|
|
|
|
"${recipient} REJECT")
|
|
|
|
(cfg.rejectRecipients));
|
|
|
|
# rejectRecipients :: [ Path ]
|
|
|
|
reject_recipients_file = builtins.toFile "reject_recipients" (lib.concatStringsSep "\n" (reject_recipients_postfix)) ;
|
|
|
|
|
2017-08-12 19:14:16 +05:00
|
|
|
# vhosts_file :: Path
|
2017-11-11 14:44:45 +05:00
|
|
|
vhosts_file = builtins.toFile "vhosts" (concatStringsSep "\n" cfg.domains);
|
2017-08-12 21:27:22 +05:00
|
|
|
|
2017-08-13 17:05:40 +05:00
|
|
|
# vaccounts_file :: Path
|
|
|
|
# see
|
|
|
|
# https://blog.grimneko.de/2011/12/24/a-bunch-of-tips-for-improving-your-postfix-setup/
|
|
|
|
# for details on how this file looks. By using the same file as valiases,
|
2018-11-23 19:29:23 +05:00
|
|
|
# every alias is owned (uniquely) by its user.
|
2018-03-03 15:43:42 +05:00
|
|
|
# The user's own address is already in all_valiases_postfix.
|
2021-01-29 03:58:08 +05:00
|
|
|
vaccounts_file = builtins.toFile "vaccounts" (lookupTableToString all_valiases_postfix);
|
2023-07-13 21:49:31 +05:00
|
|
|
regex_vaccounts_file = builtins.toFile "regex_vaccounts" (lookupTableToString regex_valiases_postfix);
|
2017-11-10 02:13:27 +05:00
|
|
|
|
2018-04-08 23:58:30 +05:00
|
|
|
submissionHeaderCleanupRules = pkgs.writeText "submission_header_cleanup_rules" (''
|
2017-09-23 12:56:09 +05:00
|
|
|
# Removes sensitive headers from mails handed in via the submission port.
|
|
|
|
# See https://thomas-leister.de/mailserver-debian-stretch/
|
|
|
|
# Uses "pcre" style regex.
|
2017-09-20 11:38:40 +05:00
|
|
|
|
|
|
|
/^Received:/ IGNORE
|
|
|
|
/^X-Originating-IP:/ IGNORE
|
|
|
|
/^X-Mailer:/ IGNORE
|
|
|
|
/^User-Agent:/ IGNORE
|
|
|
|
/^X-Enigmail:/ IGNORE
|
2018-04-08 23:58:30 +05:00
|
|
|
'' + lib.optionalString cfg.rewriteMessageId ''
|
|
|
|
|
|
|
|
# Replaces the user submitted hostname with the server's FQDN to hide the
|
|
|
|
# user's host or network.
|
|
|
|
|
|
|
|
/^Message-ID:\s+<(.*?)@.*?>/ REPLACE Message-ID: <$1@${cfg.fqdn}>
|
|
|
|
'');
|
2018-05-04 21:17:51 +05:00
|
|
|
|
|
|
|
inetSocket = addr: port: "inet:[${toString port}@${addr}]";
|
|
|
|
unixSocket = sock: "unix:${sock}";
|
|
|
|
|
|
|
|
smtpdMilters =
|
|
|
|
(lib.optional cfg.dkimSigning "unix:/run/opendkim/opendkim.sock")
|
2018-05-13 06:35:03 +05:00
|
|
|
++ [ "unix:/run/rspamd/rspamd-milter.sock" ];
|
2018-05-12 21:02:37 +05:00
|
|
|
|
2020-12-23 13:37:57 +05:00
|
|
|
policyd-spf = pkgs.writeText "policyd-spf.conf" cfg.policydSPFExtraConfig;
|
2018-11-10 18:29:16 +05:00
|
|
|
|
|
|
|
mappedFile = name: "hash:/var/lib/postfix/conf/${name}";
|
2023-07-13 21:49:31 +05:00
|
|
|
mappedRegexFile = name: "pcre:/var/lib/postfix/conf/${name}";
|
2020-07-06 13:38:12 +05:00
|
|
|
|
|
|
|
submissionOptions =
|
|
|
|
{
|
|
|
|
smtpd_tls_security_level = "encrypt";
|
|
|
|
smtpd_sasl_auth_enable = "yes";
|
|
|
|
smtpd_sasl_type = "dovecot";
|
|
|
|
smtpd_sasl_path = "/run/dovecot2/auth";
|
|
|
|
smtpd_sasl_security_options = "noanonymous";
|
|
|
|
smtpd_sasl_local_domain = "$myhostname";
|
|
|
|
smtpd_client_restrictions = "permit_sasl_authenticated,reject";
|
2023-07-13 21:49:31 +05:00
|
|
|
smtpd_sender_login_maps = "hash:/etc/postfix/vaccounts${lib.optionalString cfg.ldap.enable ",ldap:${ldapSenderLoginMapFile}"}${lib.optionalString (regex_valiases_postfix != {}) ",pcre:/etc/postfix/regex_vaccounts"}";
|
2020-07-06 13:38:12 +05:00
|
|
|
smtpd_sender_restrictions = "reject_sender_login_mismatch";
|
|
|
|
smtpd_recipient_restrictions = "reject_non_fqdn_recipient,reject_unknown_recipient_domain,permit_sasl_authenticated,reject";
|
|
|
|
cleanup_service_name = "submission-header-cleanup";
|
|
|
|
};
|
2022-07-20 02:45:29 +05:00
|
|
|
|
2023-05-20 03:12:02 +05:00
|
|
|
commonLdapConfig = ''
|
2022-07-20 02:45:29 +05:00
|
|
|
server_host = ${lib.concatStringsSep " " cfg.ldap.uris}
|
|
|
|
start_tls = ${if cfg.ldap.startTls then "yes" else "no"}
|
|
|
|
version = 3
|
|
|
|
tls_ca_cert_file = ${cfg.ldap.tlsCAFile}
|
|
|
|
tls_require_cert = yes
|
|
|
|
|
|
|
|
search_base = ${cfg.ldap.searchBase}
|
|
|
|
scope = ${cfg.ldap.searchScope}
|
|
|
|
|
|
|
|
bind = yes
|
|
|
|
bind_dn = ${cfg.ldap.bind.dn}
|
|
|
|
'';
|
|
|
|
|
2023-05-20 03:12:02 +05:00
|
|
|
ldapSenderLoginMap = pkgs.writeText "ldap-sender-login-map.cf" ''
|
|
|
|
${commonLdapConfig}
|
|
|
|
query_filter = ${cfg.ldap.postfix.filter}
|
|
|
|
result_attribute = ${cfg.ldap.postfix.mailAttribute}
|
|
|
|
'';
|
|
|
|
ldapSenderLoginMapFile = "/run/postfix/ldap-sender-login-map.cf";
|
|
|
|
appendPwdInSenderLoginMap = appendLdapBindPwd {
|
|
|
|
name = "ldap-sender-login-map";
|
|
|
|
file = ldapSenderLoginMap;
|
|
|
|
prefix = "bind_pw = ";
|
|
|
|
passwordFile = cfg.ldap.bind.passwordFile;
|
|
|
|
destination = ldapSenderLoginMapFile;
|
|
|
|
};
|
|
|
|
|
|
|
|
ldapVirtualMailboxMap = pkgs.writeText "ldap-virtual-mailbox-map.cf" ''
|
|
|
|
${commonLdapConfig}
|
|
|
|
query_filter = ${cfg.ldap.postfix.filter}
|
|
|
|
result_attribute = ${cfg.ldap.postfix.uidAttribute}
|
|
|
|
'';
|
|
|
|
ldapVirtualMailboxMapFile = "/run/postfix/ldap-virtual-mailbox-map.cf";
|
|
|
|
appendPwdInVirtualMailboxMap = appendLdapBindPwd {
|
|
|
|
name = "ldap-virtual-mailbox-map";
|
|
|
|
file = ldapVirtualMailboxMap;
|
|
|
|
prefix = "bind_pw = ";
|
|
|
|
passwordFile = cfg.ldap.bind.passwordFile;
|
|
|
|
destination = ldapVirtualMailboxMapFile;
|
|
|
|
};
|
2017-08-12 19:14:16 +05:00
|
|
|
in
|
2016-07-25 20:48:40 +05:00
|
|
|
{
|
2017-09-03 14:13:34 +05:00
|
|
|
config = with cfg; lib.mkIf enable {
|
2017-08-12 19:14:16 +05:00
|
|
|
|
2023-05-20 03:12:02 +05:00
|
|
|
systemd.services.postfix-setup = lib.mkIf cfg.ldap.enable {
|
|
|
|
preStart = ''
|
|
|
|
${appendPwdInVirtualMailboxMap}
|
|
|
|
${appendPwdInSenderLoginMap}
|
|
|
|
'';
|
|
|
|
restartTriggers = [ appendPwdInVirtualMailboxMap appendPwdInSenderLoginMap ];
|
|
|
|
};
|
|
|
|
|
2017-09-03 14:13:34 +05:00
|
|
|
services.postfix = {
|
|
|
|
enable = true;
|
2020-09-06 01:23:15 +05:00
|
|
|
hostname = "${sendingFqdn}";
|
2017-09-03 14:13:34 +05:00
|
|
|
networksStyle = "host";
|
|
|
|
mapFiles."valias" = valiases_file;
|
2023-07-13 21:49:31 +05:00
|
|
|
mapFiles."regex_valias" = regex_valiases_file;
|
2017-11-10 02:13:27 +05:00
|
|
|
mapFiles."vaccounts" = vaccounts_file;
|
2023-07-13 21:49:31 +05:00
|
|
|
mapFiles."regex_vaccounts" = regex_vaccounts_file;
|
2019-10-17 00:51:45 +05:00
|
|
|
mapFiles."denied_recipients" = denied_recipients_file;
|
2018-11-10 18:29:16 +05:00
|
|
|
mapFiles."reject_senders" = reject_senders_file;
|
2018-04-15 04:37:30 +05:00
|
|
|
mapFiles."reject_recipients" = reject_recipients_file;
|
2017-09-03 14:13:34 +05:00
|
|
|
sslCert = certificatePath;
|
|
|
|
sslKey = keyPath;
|
2020-07-06 13:38:12 +05:00
|
|
|
enableSubmission = cfg.enableSubmission;
|
|
|
|
enableSubmissions = cfg.enableSubmissionSsl;
|
2021-01-29 03:58:08 +05:00
|
|
|
virtual = lookupTableToString (mergeLookupTables [all_valiases_postfix catchAllPostfix forwards]);
|
2017-08-12 19:14:16 +05:00
|
|
|
|
2020-05-22 15:19:50 +05:00
|
|
|
config = {
|
2017-09-13 01:47:13 +05:00
|
|
|
# Extra Config
|
2020-05-22 15:19:50 +05:00
|
|
|
mydestination = "";
|
2021-03-23 00:05:34 +05:00
|
|
|
recipient_delimiter = cfg.recipientDelimiter;
|
2020-05-22 15:19:50 +05:00
|
|
|
smtpd_banner = "${fqdn} ESMTP NO UCE";
|
|
|
|
disable_vrfy_command = true;
|
|
|
|
message_size_limit = toString cfg.messageSizeLimit;
|
2017-08-12 19:14:16 +05:00
|
|
|
|
2017-09-03 14:13:34 +05:00
|
|
|
# virtual mail system
|
2020-05-22 15:19:50 +05:00
|
|
|
virtual_uid_maps = "static:5000";
|
|
|
|
virtual_gid_maps = "static:5000";
|
|
|
|
virtual_mailbox_base = mailDirectory;
|
|
|
|
virtual_mailbox_domains = vhosts_file;
|
2022-07-20 02:45:29 +05:00
|
|
|
virtual_mailbox_maps = [
|
|
|
|
(mappedFile "valias")
|
|
|
|
] ++ lib.optionals (cfg.ldap.enable) [
|
2023-05-20 03:12:02 +05:00
|
|
|
"ldap:${ldapVirtualMailboxMapFile}"
|
2023-07-13 21:49:31 +05:00
|
|
|
] ++ lib.optionals (regex_valiases_postfix != {}) [
|
|
|
|
(mappedRegexFile "regex_valias")
|
2022-07-20 02:45:29 +05:00
|
|
|
];
|
2023-07-13 21:49:31 +05:00
|
|
|
virtual_alias_maps = lib.mkAfter (lib.optionals (regex_valiases_postfix != {}) [
|
|
|
|
(mappedRegexFile "regex_valias")
|
|
|
|
]);
|
2020-05-22 15:19:50 +05:00
|
|
|
virtual_transport = "lmtp:unix:/run/dovecot2/dovecot-lmtp";
|
2021-08-11 14:18:24 +05:00
|
|
|
# Avoid leakage of X-Original-To, X-Delivered-To headers between recipients
|
|
|
|
lmtp_destination_recipient_limit = "1";
|
2017-08-12 19:14:16 +05:00
|
|
|
|
2017-09-03 14:13:34 +05:00
|
|
|
# sasl with dovecot
|
2020-05-22 15:19:50 +05:00
|
|
|
smtpd_sasl_type = "dovecot";
|
|
|
|
smtpd_sasl_path = "/run/dovecot2/auth";
|
|
|
|
smtpd_sasl_auth_enable = true;
|
|
|
|
smtpd_relay_restrictions = [
|
|
|
|
"permit_mynetworks" "permit_sasl_authenticated" "reject_unauth_destination"
|
|
|
|
];
|
2017-09-20 12:26:42 +05:00
|
|
|
|
2020-05-22 15:19:50 +05:00
|
|
|
policy-spf_time_limit = "3600s";
|
2018-05-12 21:02:37 +05:00
|
|
|
|
2018-11-10 18:29:16 +05:00
|
|
|
# reject selected senders
|
2020-05-22 15:19:50 +05:00
|
|
|
smtpd_sender_restrictions = [
|
|
|
|
"check_sender_access ${mappedFile "reject_senders"}"
|
|
|
|
];
|
2018-11-10 18:29:16 +05:00
|
|
|
|
2018-05-12 21:02:37 +05:00
|
|
|
# quota and spf checking
|
2020-05-22 15:19:50 +05:00
|
|
|
smtpd_recipient_restrictions = [
|
|
|
|
"check_recipient_access ${mappedFile "denied_recipients"}"
|
|
|
|
"check_recipient_access ${mappedFile "reject_recipients"}"
|
|
|
|
"check_policy_service inet:localhost:12340"
|
|
|
|
"check_policy_service unix:private/policy-spf"
|
|
|
|
];
|
2017-12-22 20:58:35 +05:00
|
|
|
|
2017-09-20 02:54:40 +05:00
|
|
|
# TLS settings, inspired by https://github.com/jeaye/nix-files
|
2017-09-20 12:26:42 +05:00
|
|
|
# Submission by mail clients is handled in submissionOptions
|
2020-05-22 15:19:50 +05:00
|
|
|
smtpd_tls_security_level = "may";
|
2019-06-21 14:09:30 +05:00
|
|
|
|
|
|
|
# Disable obselete protocols
|
2020-05-22 15:19:50 +05:00
|
|
|
smtpd_tls_protocols = "TLSv1.3, TLSv1.2, TLSv1.1, !TLSv1, !SSLv2, !SSLv3";
|
|
|
|
smtp_tls_protocols = "TLSv1.3, TLSv1.2, TLSv1.1, !TLSv1, !SSLv2, !SSLv3";
|
|
|
|
smtpd_tls_mandatory_protocols = "TLSv1.3, TLSv1.2, TLSv1.1, !TLSv1, !SSLv2, !SSLv3";
|
|
|
|
smtp_tls_mandatory_protocols = "TLSv1.3, TLSv1.2, TLSv1.1, !TLSv1, !SSLv2, !SSLv3";
|
2019-06-21 14:09:30 +05:00
|
|
|
|
2020-05-22 15:19:50 +05:00
|
|
|
smtp_tls_ciphers = "high";
|
|
|
|
smtpd_tls_ciphers = "high";
|
|
|
|
smtp_tls_mandatory_ciphers = "high";
|
|
|
|
smtpd_tls_mandatory_ciphers = "high";
|
2019-06-21 14:09:30 +05:00
|
|
|
|
|
|
|
# Disable deprecated ciphers
|
2020-05-22 15:19:50 +05:00
|
|
|
smtpd_tls_mandatory_exclude_ciphers = "MD5, DES, ADH, RC4, PSD, SRP, 3DES, eNULL, aNULL";
|
|
|
|
smtpd_tls_exclude_ciphers = "MD5, DES, ADH, RC4, PSD, SRP, 3DES, eNULL, aNULL";
|
|
|
|
smtp_tls_mandatory_exclude_ciphers = "MD5, DES, ADH, RC4, PSD, SRP, 3DES, eNULL, aNULL";
|
|
|
|
smtp_tls_exclude_ciphers = "MD5, DES, ADH, RC4, PSD, SRP, 3DES, eNULL, aNULL";
|
2019-06-21 14:09:30 +05:00
|
|
|
|
2020-05-22 15:19:50 +05:00
|
|
|
tls_preempt_cipherlist = true;
|
2019-06-21 14:09:30 +05:00
|
|
|
|
2017-09-20 12:26:42 +05:00
|
|
|
# Allowing AUTH on a non encrypted connection poses a security risk
|
2020-05-22 15:19:50 +05:00
|
|
|
smtpd_tls_auth_only = true;
|
2017-09-20 12:26:42 +05:00
|
|
|
# Log only a summary message on TLS handshake completion
|
2020-05-22 15:19:50 +05:00
|
|
|
smtpd_tls_loglevel = "1";
|
2017-09-20 12:26:42 +05:00
|
|
|
|
2017-09-20 02:54:40 +05:00
|
|
|
# Configure a non blocking source of randomness
|
2020-05-22 15:19:50 +05:00
|
|
|
tls_random_source = "dev:/dev/urandom";
|
2018-05-04 21:17:51 +05:00
|
|
|
|
2020-05-22 15:19:50 +05:00
|
|
|
smtpd_milters = smtpdMilters;
|
|
|
|
non_smtpd_milters = lib.mkIf cfg.dkimSigning ["unix:/run/opendkim/opendkim.sock"];
|
|
|
|
milter_protocol = "6";
|
|
|
|
milter_mail_macros = "i {mail_addr} {client_addr} {client_name} {auth_type} {auth_authen} {auth_author} {mail_addr} {mail_host} {mail_mailer}";
|
2017-08-12 19:14:16 +05:00
|
|
|
|
2023-12-27 13:46:26 +05:00
|
|
|
# Fix for https://www.postfix.org/smtp-smuggling.html
|
2023-12-24 00:15:16 +05:00
|
|
|
smtpd_forbid_bare_newline = cfg.smtpdForbidBareNewline;
|
2023-12-27 13:46:26 +05:00
|
|
|
smtpd_forbid_bare_newline_exclusions = "$mynetworks";
|
2020-05-22 15:19:50 +05:00
|
|
|
};
|
2020-07-06 13:38:12 +05:00
|
|
|
|
|
|
|
submissionOptions = submissionOptions;
|
|
|
|
submissionsOptions = submissionOptions;
|
|
|
|
|
2018-05-12 21:00:14 +05:00
|
|
|
masterConfig = {
|
2021-08-11 14:18:24 +05:00
|
|
|
"lmtp" = {
|
|
|
|
# Add headers when delivering, see http://www.postfix.org/smtp.8.html
|
|
|
|
# D => Delivered-To, O => X-Original-To, R => Return-Path
|
|
|
|
args = [ "flags=O" ];
|
|
|
|
};
|
2018-05-12 21:02:37 +05:00
|
|
|
"policy-spf" = {
|
|
|
|
type = "unix";
|
|
|
|
privileged = true;
|
|
|
|
chroot = false;
|
|
|
|
command = "spawn";
|
2024-06-14 20:16:40 +05:00
|
|
|
args = [ "user=nobody" "argv=${pkgs.spf-engine}/bin/policyd-spf" "${policyd-spf}"];
|
2018-05-12 21:02:37 +05:00
|
|
|
};
|
2018-05-12 21:00:14 +05:00
|
|
|
"submission-header-cleanup" = {
|
|
|
|
type = "unix";
|
|
|
|
private = false;
|
|
|
|
chroot = false;
|
|
|
|
maxproc = 0;
|
|
|
|
command = "cleanup";
|
|
|
|
args = ["-o" "header_checks=pcre:${submissionHeaderCleanupRules}"];
|
|
|
|
};
|
|
|
|
};
|
2017-09-03 14:13:34 +05:00
|
|
|
};
|
2017-08-13 17:05:40 +05:00
|
|
|
};
|
2016-07-25 20:48:40 +05:00
|
|
|
}
|