mirror of
https://github.com/docker-mailserver/docker-mailserver.git
synced 2024-01-19 02:48:50 +00:00
Added virtual aliases management using dedicated env variable.
This commit is contained in:
parent
50e96ab406
commit
81c08b82d5
|
@ -16,6 +16,7 @@ Additional informations:
|
||||||
- mails are stored in `/var/mail/${domain}/${username}`
|
- mails are stored in `/var/mail/${domain}/${username}`
|
||||||
- email login are full email address (`username1@my-domain.com`)
|
- email login are full email address (`username1@my-domain.com`)
|
||||||
- ssl is strongly recommended
|
- ssl is strongly recommended
|
||||||
|
- do not add whitespace in `$docker_mail_users` or `$docker_mail_aliases`
|
||||||
|
|
||||||
## installation
|
## installation
|
||||||
|
|
||||||
|
@ -28,8 +29,7 @@ Additional informations:
|
||||||
## docker-compose template
|
## docker-compose template
|
||||||
|
|
||||||
mail:
|
mail:
|
||||||
build: .
|
image: tvial/docker-mailserver
|
||||||
# or use 'image: tvial/docker-mailserver'
|
|
||||||
hostname: mail
|
hostname: mail
|
||||||
domainname: my-domain.com
|
domainname: my-domain.com
|
||||||
ports:
|
ports:
|
||||||
|
@ -43,6 +43,9 @@ Additional informations:
|
||||||
docker_mail_users:
|
docker_mail_users:
|
||||||
- "username1@my-domain.com|username1password"
|
- "username1@my-domain.com|username1password"
|
||||||
- "username2@my-domain.com|username2password"
|
- "username2@my-domain.com|username2password"
|
||||||
|
docker_mail_aliases:
|
||||||
|
- "username1@my-domain.com|alias1,alias2,alias3"
|
||||||
|
- "username2@my-domain.com|alias4"
|
||||||
|
|
||||||
# todo
|
# todo
|
||||||
|
|
||||||
|
|
|
@ -2,8 +2,6 @@
|
||||||
|
|
||||||
echo "Regenerating 'vmailbox' for given users"
|
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 "# 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
|
echo $docker_mail_users | sed -r 's/\[|\]|\x27| //g' | sed -r 's/,/\n/g' > /tmp/docker_mail_users
|
||||||
while IFS=$'|' read -r login pass
|
while IFS=$'|' read -r login pass
|
||||||
|
@ -26,6 +24,20 @@ done < /tmp/docker_mail_users
|
||||||
rm /tmp/docker_mail_users
|
rm /tmp/docker_mail_users
|
||||||
makeuserdb
|
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"
|
echo "Postfix configurations"
|
||||||
postmap /etc/postfix/vmailbox
|
postmap /etc/postfix/vmailbox
|
||||||
touch /etc/postfix/virtual && postmap /etc/postfix/virtual
|
touch /etc/postfix/virtual && postmap /etc/postfix/virtual
|
||||||
|
|
Loading…
Reference in a new issue