From 23362190a8db7b04ebe602bdaf1cefb7d3719501 Mon Sep 17 00:00:00 2001 From: egavard Date: Wed, 5 Aug 2015 11:58:10 +0200 Subject: [PATCH 1/8] Trying to separate virtuals from accounts --- postfix/accounts.cf | 2 +- postfix/redirects.cf | 1 + start-mailserver.sh | 10 +++++++++- 3 files changed, 11 insertions(+), 2 deletions(-) create mode 100644 postfix/redirects.cf diff --git a/postfix/accounts.cf b/postfix/accounts.cf index 1489b4d7..94896e0d 100644 --- a/postfix/accounts.cf +++ b/postfix/accounts.cf @@ -1 +1 @@ -user@domain.tld|mypassword|alias1,alias2 \ No newline at end of file +user@domain.tld|mypassword \ No newline at end of file diff --git a/postfix/redirects.cf b/postfix/redirects.cf new file mode 100644 index 00000000..40eaea6a --- /dev/null +++ b/postfix/redirects.cf @@ -0,0 +1 @@ +user@domain.tld | otheruser@domain.tld otheruser@otherdomain.tld \ No newline at end of file diff --git a/start-mailserver.sh b/start-mailserver.sh index d4f07b01..c85191b0 100644 --- a/start-mailserver.sh +++ b/start-mailserver.sh @@ -6,7 +6,8 @@ echo "Regenerating postfix 'vmailbox' and 'virtual' for given users" # rm /etc/postfix/vmailbox # rm /etc/postfix/vmailbox.db echo "# WARNING: this file is auto-generated. Do not modify locally" > /etc/postfix/vmailbox -while IFS=$'|' read -r login pass aliases +# Creating users +while IFS=$'|' read -r login pass do # Setting variables for better readability @@ -33,6 +34,13 @@ do done < /tmp/postfix/accounts.cf makeuserdb +#creating virtuals +while IFS=$'|' read -r from to +do + echo "from : '$from' aliases: '$to'" + # Let's go! + echo "$from\t$to" >> /etc/postfix/virtual +done < /tmp/postfix/redirects.cf echo "Postfix configurations" postmap /etc/postfix/vmailbox From 5abadead333ae663a059cc62462d6fe86d359f69 Mon Sep 17 00:00:00 2001 From: egavard Date: Wed, 5 Aug 2015 12:09:24 +0200 Subject: [PATCH 2/8] Virtuals to must be separated with comma in order to be used directly. --- postfix/redirects.cf | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/postfix/redirects.cf b/postfix/redirects.cf index 40eaea6a..c29ec5cc 100644 --- a/postfix/redirects.cf +++ b/postfix/redirects.cf @@ -1 +1 @@ -user@domain.tld | otheruser@domain.tld otheruser@otherdomain.tld \ No newline at end of file +user@domain.tld | otheruser@domain.tld,otheruser@otherdomain.tld \ No newline at end of file From b057ad2170ab6046c63d0d26de5d0c80c951eb11 Mon Sep 17 00:00:00 2001 From: egavard Date: Wed, 5 Aug 2015 12:09:53 +0200 Subject: [PATCH 3/8] Modified warning in virtual and vmailbox --- start-mailserver.sh | 13 +++---------- 1 file changed, 3 insertions(+), 10 deletions(-) diff --git a/start-mailserver.sh b/start-mailserver.sh index c85191b0..dcac9d69 100644 --- a/start-mailserver.sh +++ b/start-mailserver.sh @@ -5,7 +5,8 @@ echo "Regenerating postfix 'vmailbox' and 'virtual' for given users" # rm /etc/postfix/virtual.db # rm /etc/postfix/vmailbox # rm /etc/postfix/vmailbox.db -echo "# WARNING: this file is auto-generated. Do not modify locally" > /etc/postfix/vmailbox +echo "# WARNING: this file is auto-generated. Modify accounts.cf in postfix directory on host" > /etc/postfix/vmailbox +echo "# WARNING: this file is auto-generated. Modify redirects.cf in postfix directory on host" > /etc/postfix/virtual # Creating users while IFS=$'|' read -r login pass do @@ -23,17 +24,9 @@ do mkdir -p /var/mail/${domain} maildirmake /var/mail/${domain}/${user} echo ${domain} >> /tmp/vhost.tmp - - # Aliases - arr=$(echo $aliases | tr "," "\n") - for alias in $arr - do - echo "$alias@$domain redirects to $login" - echo "$alias@$domain\t$login" >> /etc/postfix/virtual - done - done < /tmp/postfix/accounts.cf makeuserdb + #creating virtuals while IFS=$'|' read -r from to do From bf8fc5949d689ed865bfbc445cd25b6c5ad78dc7 Mon Sep 17 00:00:00 2001 From: egavard Date: Wed, 5 Aug 2015 13:29:05 +0200 Subject: [PATCH 4/8] Updated accounts and redirects cf files --- postfix/accounts.cf | 2 +- postfix/redirects.cf | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/postfix/accounts.cf b/postfix/accounts.cf index 94896e0d..ecb0f063 100644 --- a/postfix/accounts.cf +++ b/postfix/accounts.cf @@ -1 +1 @@ -user@domain.tld|mypassword \ No newline at end of file +user@domain.tld|mypassword diff --git a/postfix/redirects.cf b/postfix/redirects.cf index c29ec5cc..492eb3a0 100644 --- a/postfix/redirects.cf +++ b/postfix/redirects.cf @@ -1 +1 @@ -user@domain.tld | otheruser@domain.tld,otheruser@otherdomain.tld \ No newline at end of file +user@domain.tld|otheruser@domain.tld,otheruser@otherdomain.tld From 15835a0ead114f54d33de27a042374754b9ae888 Mon Sep 17 00:00:00 2001 From: GAVARD Ewann Date: Wed, 5 Aug 2015 13:35:22 +0200 Subject: [PATCH 5/8] Update README.md --- README.md | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/README.md b/README.md index c2505524..d124ffd0 100644 --- a/README.md +++ b/README.md @@ -20,8 +20,9 @@ Additional informations: - ssl is strongly recommended - do not add whitespace in `$docker_mail_users` or `$docker_mail_aliases` - user accounts are managed in `./postfix/accounts.cf` +- redirections are managed in `./postfix/redirects.cf` - antispam are rules are managed in `./spamassassin/rules.cf` -- both files must be mounted to `/tmp` in your container (see `docker-compose.yml` template) +- files must be mounted to `/tmp` in your container (see `docker-compose.yml` template) ## installation From 3eb0a13b37f10c888cf13f4e23903bdba46cd071 Mon Sep 17 00:00:00 2001 From: egavard Date: Thu, 6 Aug 2015 10:54:22 +0200 Subject: [PATCH 6/8] Now using virtual file directly from /tmp/postfix folder. --- postfix/redirects.cf | 1 - postfix/virtual | 4 ++++ start-mailserver.sh | 10 ++-------- 3 files changed, 6 insertions(+), 9 deletions(-) delete mode 100644 postfix/redirects.cf create mode 100644 postfix/virtual diff --git a/postfix/redirects.cf b/postfix/redirects.cf deleted file mode 100644 index c29ec5cc..00000000 --- a/postfix/redirects.cf +++ /dev/null @@ -1 +0,0 @@ -user@domain.tld | otheruser@domain.tld,otheruser@otherdomain.tld \ No newline at end of file diff --git a/postfix/virtual b/postfix/virtual new file mode 100644 index 00000000..9fc19fb0 --- /dev/null +++ b/postfix/virtual @@ -0,0 +1,4 @@ +#Mail redirection from user@domain.tld to otheruser@domain.tld and otheruser@otherdomain.tld +user@domain.tld|otheruser@domain.tld,otheruser@otherdomain.tld +#Mail redirection from postmaster@domain.tld and hostmaster@domain.tld to user@domain.tld +user@domain.tld| postmaster,hostmaster \ No newline at end of file diff --git a/start-mailserver.sh b/start-mailserver.sh index dcac9d69..ba6ab200 100644 --- a/start-mailserver.sh +++ b/start-mailserver.sh @@ -27,14 +27,8 @@ do done < /tmp/postfix/accounts.cf makeuserdb -#creating virtuals -while IFS=$'|' read -r from to -do - echo "from : '$from' aliases: '$to'" - # Let's go! - echo "$from\t$to" >> /etc/postfix/virtual -done < /tmp/postfix/redirects.cf - +#creating virtuals and redirects +cp /tmp/postfix/virtual /etc/postfix/virtual echo "Postfix configurations" postmap /etc/postfix/vmailbox postmap /etc/postfix/virtual From b70f9ee3fb72cac7dc64620475db6953349e3ff7 Mon Sep 17 00:00:00 2001 From: egavard Date: Thu, 6 Aug 2015 12:14:04 +0200 Subject: [PATCH 7/8] Updated virtual structure (key space value) --- postfix/virtual | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/postfix/virtual b/postfix/virtual index 9fc19fb0..7718604a 100644 --- a/postfix/virtual +++ b/postfix/virtual @@ -1,4 +1,4 @@ #Mail redirection from user@domain.tld to otheruser@domain.tld and otheruser@otherdomain.tld -user@domain.tld|otheruser@domain.tld,otheruser@otherdomain.tld +user1@domain.tld otheruser@domain.tld otheruser@otherdomain.tld #Mail redirection from postmaster@domain.tld and hostmaster@domain.tld to user@domain.tld -user@domain.tld| postmaster,hostmaster \ No newline at end of file +user2@domain.tld postmaster hostmaster \ No newline at end of file From 3f3fcb2a6ed773d752def30465613fa386e416a6 Mon Sep 17 00:00:00 2001 From: GAVARD Ewann Date: Fri, 7 Aug 2015 09:19:38 +0200 Subject: [PATCH 8/8] Removed useless echo in virtual file. --- start-mailserver.sh | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/start-mailserver.sh b/start-mailserver.sh index ba6ab200..dd845180 100644 --- a/start-mailserver.sh +++ b/start-mailserver.sh @@ -6,7 +6,6 @@ echo "Regenerating postfix 'vmailbox' and 'virtual' for given users" # rm /etc/postfix/vmailbox # rm /etc/postfix/vmailbox.db echo "# WARNING: this file is auto-generated. Modify accounts.cf in postfix directory on host" > /etc/postfix/vmailbox -echo "# WARNING: this file is auto-generated. Modify redirects.cf in postfix directory on host" > /etc/postfix/virtual # Creating users while IFS=$'|' read -r login pass do @@ -27,8 +26,9 @@ do done < /tmp/postfix/accounts.cf makeuserdb -#creating virtuals and redirects +#copying virtual file cp /tmp/postfix/virtual /etc/postfix/virtual + echo "Postfix configurations" postmap /etc/postfix/vmailbox postmap /etc/postfix/virtual