From e93c6cce73108c60776f773d52168f6aed9cf008 Mon Sep 17 00:00:00 2001 From: Dominic Ricottone Date: Wed, 21 Jun 2023 23:53:54 -0500 Subject: [PATCH] Adding recipient_canonical maps to Postfix --- postfix/README.md | 9 ++++++++- postfix/entrypoint.sh | 1 + postfix/main.cf | 1 + postfix/main.cf.tls-in | 1 + postfix/main.cf.tls-out | 1 + 5 files changed, 12 insertions(+), 1 deletion(-) diff --git a/postfix/README.md b/postfix/README.md index 91c069d..f16c661 100644 --- a/postfix/README.md +++ b/postfix/README.md @@ -21,7 +21,7 @@ make image Can be used with any container manager toolchain. Create a `generic(5)` file in `$genericfile`. -Mail with recipient addresses matching the patterns will be rewritten. +Addresses matching the patterns will be rewritten. It must also be owned (on the host system) by the user that will create the container (i.e. `root` for conventional `docker(1)` deployments). It should like like: @@ -31,6 +31,12 @@ root@localhost example@gmail.com @localhost example@gmail.com ``` +If instead an address should only be rewritten when it is a recipient address, +create a `canonical(5)` file in `$canonicalfile`. +It should look the same way. +It must also be owned (on the host system) by the user that will create the +container (i.e. `root` for conventional `docker(1)` deployments). + Create a `transport(5)` file in `$transportfile`. Mail is routed based on which pattern the recipient address matches. It must also be owned (on the host system) by the user that will create the @@ -70,6 +76,7 @@ Try: ``` $conman run --detach --name postfix --restart always \ --mount type=bind,src=$genericfile,dst=/etc/postfix/generic,readonly \ + --mount type=bind,src=$canonicalfile,dst=/etc/postfix/recipient_canonical,readonly \ --mount type=bind,src=$transportfile,dst=/etc/postfix/transport,readonly \ --mount type=bind,src=$saslfile,dst=/etc/postfix/sasl/sasl_passwd,readonly \ --mount type=bind,src=$sasldb,dst=/etc/sasl2/sasldb2,readonly \ diff --git a/postfix/entrypoint.sh b/postfix/entrypoint.sh index 37dab2c..30fe1d0 100644 --- a/postfix/entrypoint.sh +++ b/postfix/entrypoint.sh @@ -2,6 +2,7 @@ newaliases postmap /etc/postfix/transport postmap /etc/postfix/generic +postmap /etc/postfix/recipient_canonical postmap /etc/postfix/sasl/sasl_passwd sed -i /etc/postfix/main.cf -e "s/^mydomain.*/mydomain = ${DOMAIN}/" diff --git a/postfix/main.cf b/postfix/main.cf index c74df29..9c2b059 100644 --- a/postfix/main.cf +++ b/postfix/main.cf @@ -18,6 +18,7 @@ smtpd_banner = $myhostname ESMTP $mail_name ($mail_version) # Address rewriting smtp_generic_maps = lmdb:/etc/postfix/generic +recipient_canonical_maps = lmdb:/etc/postfix/recipient_canonical # Transport map transport_maps = lmdb:/etc/postfix/transport diff --git a/postfix/main.cf.tls-in b/postfix/main.cf.tls-in index d770fef..1f5e6c6 100644 --- a/postfix/main.cf.tls-in +++ b/postfix/main.cf.tls-in @@ -18,6 +18,7 @@ smtpd_banner = $myhostname ESMTP $mail_name ($mail_version) # Address rewriting smtp_generic_maps = lmdb:/etc/postfix/generic +recipient_canonical_maps = lmdb:/etc/postfix/recipient_canonical # Transport map smtp_dns_support_level = disabled diff --git a/postfix/main.cf.tls-out b/postfix/main.cf.tls-out index 7f1e6b0..cfa8f03 100644 --- a/postfix/main.cf.tls-out +++ b/postfix/main.cf.tls-out @@ -18,6 +18,7 @@ smtpd_banner = $myhostname ESMTP $mail_name ($mail_version) # Address rewriting smtp_generic_maps = lmdb:/etc/postfix/generic +recipient_canonical_maps = lmdb:/etc/postfix/recipient_canonical # Transport map transport_maps = lmdb:/etc/postfix/transport -- 2.45.2