Added virtual aliases management using dedicated env variable.

This commit is contained in:
Thomas VIAL 2015-05-02 19:05:34 +02:00
parent 50e96ab406
commit 81c08b82d5
2 changed files with 31 additions and 16 deletions

View file

@ -16,6 +16,7 @@ Additional informations:
- mails are stored in `/var/mail/${domain}/${username}`
- email login are full email address (`username1@my-domain.com`)
- ssl is strongly recommended
- do not add whitespace in `$docker_mail_users` or `$docker_mail_aliases`
## installation
@ -28,8 +29,7 @@ Additional informations:
## docker-compose template
mail:
build: .
# or use 'image: tvial/docker-mailserver'
image: tvial/docker-mailserver
hostname: mail
domainname: my-domain.com
ports:
@ -43,6 +43,9 @@ Additional informations:
docker_mail_users:
- "username1@my-domain.com|username1password"
- "username2@my-domain.com|username2password"
docker_mail_aliases:
- "username1@my-domain.com|alias1,alias2,alias3"
- "username2@my-domain.com|alias4"
# todo

View file

@ -2,8 +2,6 @@
echo "Regenerating 'vmailbox' for given users"
echo "docker_mail_users => $docker_mail_users"
echo "# WARNING: this file is auto-generated. Do not modify locally" > /etc/postfix/vmailbox
echo $docker_mail_users | sed -r 's/\[|\]|\x27| //g' | sed -r 's/,/\n/g' > /tmp/docker_mail_users
while IFS=$'|' read -r login pass
@ -26,6 +24,20 @@ done < /tmp/docker_mail_users
rm /tmp/docker_mail_users
makeuserdb
echo "Regenerating 'virtual' for given aliases"
echo $docker_mail_aliases | sed -r 's/\[|\]|\x27|//g' | sed -r 's/, /\n/g' > /tmp/docker_mail_aliases
while IFS=$'|' read -r login aliases
do
arr=$(echo $aliases | tr "," "\n")
for alias in $arr
do
user=$(echo ${login} | cut -d @ -f1)
domain=$(echo ${login} | cut -d @ -f2)
echo "$alias@$domain redirects to $login"
echo "$alias@$domain\t$login" >> /etc/postfix/virtual
done
done < /tmp/docker_mail_aliases
echo "Postfix configurations"
postmap /etc/postfix/vmailbox
touch /etc/postfix/virtual && postmap /etc/postfix/virtual