From 61c34d10390d72c1091938205db8cf72a0313c0b Mon Sep 17 00:00:00 2001 From: Jakub Czajka Date: Mon, 1 May 2023 11:42:56 +0200 Subject: [PATCH] [postfix] Deliver to addresses found in the address book. `postfix` relays to local mailbox only if the RCPT TO domain can be found in `$mydestination` and RCPT TO address can be found in `$alias_maps`. This commit sets these variables to query the address book. --- postfix/domains.cf | 8 ++++++++ postfix/main.cf | 6 ++++++ 2 files changed, 14 insertions(+) create mode 100644 postfix/domains.cf diff --git a/postfix/domains.cf b/postfix/domains.cf new file mode 100644 index 0000000..a3b27e6 --- /dev/null +++ b/postfix/domains.cf @@ -0,0 +1,8 @@ +user = dovecot +password = + +dbname = mail_db + +query = SELECT DISTINCT domain + FROM users + WHERE domain = '%s' diff --git a/postfix/main.cf b/postfix/main.cf index d47f02c..8981eae 100644 --- a/postfix/main.cf +++ b/postfix/main.cf @@ -25,6 +25,12 @@ smtpd_tls_key_file = ${mail_ssl_cert_dir}/privkey.pem smtpd_tls_mandatory_ciphers = high smtpd_tls_security_level = encrypt +# SMTPd +## Domain names of local (no forward) recipients. +mydestination = pgsql:/etc/postfix/domains.cf +## Addresses of local recipients. +alias_maps = pgsql:/etc/postfix/address_book.cf +## Deliver to dovecot. mailbox_transport = lmtp:unix:private/dovecot-lmtp # Message rewrite -- 2.39.5