Merge pull request #11 from dy0nysos/dev
Now `aliases` and `redirects` are managed in static files copied to `postfix` directory.
This commit is contained in:
commit
e8107b4ecc
|
@ -20,8 +20,9 @@ Additional informations:
|
||||||
- ssl is strongly recommended
|
- ssl is strongly recommended
|
||||||
- do not add whitespace in `$docker_mail_users` or `$docker_mail_aliases`
|
- do not add whitespace in `$docker_mail_users` or `$docker_mail_aliases`
|
||||||
- user accounts are managed in `./postfix/accounts.cf`
|
- user accounts are managed in `./postfix/accounts.cf`
|
||||||
|
- redirections are managed in `./postfix/redirects.cf`
|
||||||
- antispam are rules are managed in `./spamassassin/rules.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
|
## installation
|
||||||
|
|
||||||
|
|
|
@ -1 +1 @@
|
||||||
user@domain.tld|mypassword|alias1,alias2
|
user@domain.tld|mypassword
|
|
@ -0,0 +1,4 @@
|
||||||
|
#Mail redirection from user@domain.tld to otheruser@domain.tld and 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
|
||||||
|
user2@domain.tld postmaster hostmaster
|
|
@ -5,8 +5,9 @@ echo "Regenerating postfix 'vmailbox' and 'virtual' for given users"
|
||||||
# rm /etc/postfix/virtual.db
|
# rm /etc/postfix/virtual.db
|
||||||
# rm /etc/postfix/vmailbox
|
# rm /etc/postfix/vmailbox
|
||||||
# rm /etc/postfix/vmailbox.db
|
# 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
|
||||||
while IFS=$'|' read -r login pass aliases
|
# Creating users
|
||||||
|
while IFS=$'|' read -r login pass
|
||||||
do
|
do
|
||||||
|
|
||||||
# Setting variables for better readability
|
# Setting variables for better readability
|
||||||
|
@ -22,18 +23,12 @@ do
|
||||||
mkdir -p /var/mail/${domain}
|
mkdir -p /var/mail/${domain}
|
||||||
maildirmake /var/mail/${domain}/${user}
|
maildirmake /var/mail/${domain}/${user}
|
||||||
echo ${domain} >> /tmp/vhost.tmp
|
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
|
done < /tmp/postfix/accounts.cf
|
||||||
makeuserdb
|
makeuserdb
|
||||||
|
|
||||||
|
#copying virtual file
|
||||||
|
cp /tmp/postfix/virtual /etc/postfix/virtual
|
||||||
|
|
||||||
echo "Postfix configurations"
|
echo "Postfix configurations"
|
||||||
postmap /etc/postfix/vmailbox
|
postmap /etc/postfix/vmailbox
|
||||||
postmap /etc/postfix/virtual
|
postmap /etc/postfix/virtual
|
||||||
|
|
Loading…
Reference in New Issue