From b985ba4f0e2f9c6b658413d38fa08b7aa4e985ea Mon Sep 17 00:00:00 2001 From: macwinnie Date: Thu, 4 Aug 2022 01:37:26 +0200 Subject: [PATCH 1/2] Improve send-as behaviour MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Receiving mails for wildcard alias addresses is really easy – but sending mails from those any-aliases was not possible at all unless every sender address was added as an explicit alias to the database. By this change in the database query for allowed sender addresses, the first finding `not NULL` (see [`SELECT COALESCE`](https://www.w3schools.com/sql/func_sqlserver_coalesce.asp) for how it works) – either an exact alias `mailbox@domain.tld` or the wildcard alias `@domain.tld` will be allowed to send mails as the given address ... without the need of explicit definition within the database. --- data/Dockerfiles/postfix/postfix.sh | 16 ++++++++++++++-- 1 file changed, 14 insertions(+), 2 deletions(-) diff --git a/data/Dockerfiles/postfix/postfix.sh b/data/Dockerfiles/postfix/postfix.sh index e734a9ab..78b070e0 100755 --- a/data/Dockerfiles/postfix/postfix.sh +++ b/data/Dockerfiles/postfix/postfix.sh @@ -323,7 +323,19 @@ hosts = unix:/var/run/mysqld/mysqld.sock dbname = ${DBNAME} # First select queries domain and alias_domain to determine if domains are active. query = SELECT goto FROM alias - WHERE address='%s' + WHERE id IN ( + SELECT COALESCE ( + ( + SELECT id FROM alias + WHERE address='%s' + AND (active='1' OR active='2') + ), ( + SELECT id FROM alias + WHERE address='@%d' + AND (active='1' OR active='2') + ) + ) + ) AND active='1' AND (domain IN (SELECT domain FROM domain @@ -354,7 +366,7 @@ query = SELECT goto FROM alias WHERE alias_domain.alias_domain = '%d' AND mailbox.username = CONCAT('%u','@',alias_domain.target_domain) AND (mailbox.active = '1' OR mailbox.active ='2') - AND alias_domain.active='1' + AND alias_domain.active='1'; EOF # MX based routing From edcf789126066d17369e94e34cee21259857e687 Mon Sep 17 00:00:00 2001 From: macwinnie Date: Fri, 5 Aug 2022 00:37:58 +0200 Subject: [PATCH 2/2] Update postfix version by +.1 Update Version of Docker-Image according to [related comment](https://github.com/mailcow/mailcow-dockerized/pull/4703#issuecomment-1205277142) --- docker-compose.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/docker-compose.yml b/docker-compose.yml index 91266e00..85e0cef8 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -295,7 +295,7 @@ services: - dovecot postfix-mailcow: - image: mailcow/postfix:1.67 + image: mailcow/postfix:1.68 depends_on: - mysql-mailcow volumes: