mirror of
https://github.com/docker-mailserver/docker-mailserver.git
synced 2024-01-19 02:48:50 +00:00
Fixes #8 - BC BREAK - User configuration is no longer in docker-compose.yml to make it easier to maintain
This commit is contained in:
parent
f79da1d3f7
commit
320156439f
|
@ -2,7 +2,7 @@ FROM ubuntu:14.04
|
|||
MAINTAINER Thomas VIAL
|
||||
|
||||
# Packages
|
||||
RUN apt-get update -q
|
||||
RUN apt-get update -q --fix-missing
|
||||
RUN apt-get -y upgrade
|
||||
RUN DEBIAN_FRONTEND=noninteractive apt-get -y install vim postfix sasl2-bin courier-imap courier-imap-ssl courier-authdaemon supervisor libfam0 fam amavisd-new spamassassin clamav-daemon libnet-dns-perl libmail-spf-perl pyzor razor arj bzip2 cabextract cpio file gzip nomarch pax unzip zip zoo rsyslog
|
||||
RUN apt-get autoclean
|
||||
|
|
21
README.md
21
README.md
|
@ -30,12 +30,13 @@ Additional informations:
|
|||
|
||||
## run
|
||||
|
||||
docker run -p "25:25" -p "143:143" -p "587:587" -p "993:993" -e docker_mail_users="username1@my-domain.com|username1password" -h mail.my-domain.com -e docker_mail_domain=my-domain.com -t tvial/docker-mailserver
|
||||
docker run -p "25:25" -p "143:143" -p "587:587" -p "993:993" -e docker_mail_domain=my-domain.com -t tvial/docker-mailserver
|
||||
|
||||
## docker-compose template (recommended)
|
||||
|
||||
mail:
|
||||
image: tvial/docker-mailserver
|
||||
# image: tvial/docker-mailserver
|
||||
build: .
|
||||
hostname: mail
|
||||
domainname: my-domain.com
|
||||
ports:
|
||||
|
@ -45,14 +46,14 @@ Additional informations:
|
|||
- "993:993"
|
||||
environment:
|
||||
docker_mail_domain: "my-domain.com"
|
||||
# format is user@domain.tld|clear_password
|
||||
docker_mail_users:
|
||||
- "username1@my-domain.com|username1password"
|
||||
- "username2@my-domain.com|username2password"
|
||||
# format is user@domain.tld|list,of,aliases,comma,separated
|
||||
docker_mail_aliases:
|
||||
- "username1@my-domain.com|alias1,alias2,alias3"
|
||||
- "username2@my-domain.com|alias4"
|
||||
volumes:
|
||||
- ./spamassassin:/tmp/spamassassin/:ro
|
||||
- ./postfix:/tmp/postfix/:ro
|
||||
|
||||
Volumes allow to:
|
||||
|
||||
- Insert custom antispam rules
|
||||
- Manage mail users, passwords and aliases
|
||||
|
||||
# usage
|
||||
docker-compose up -d mail
|
||||
|
|
|
@ -10,11 +10,6 @@ mail:
|
|||
- "993:993"
|
||||
environment:
|
||||
docker_mail_domain: "my-domain.com"
|
||||
# format is user@domain.tld|clear_password
|
||||
docker_mail_users:
|
||||
- "username1@my-domain.com|username1password"
|
||||
- "username2@my-domain.com|username2password"
|
||||
# format is user@domain.tld|list,of,aliases,comma,separated
|
||||
docker_mail_aliases:
|
||||
- "username1@my-domain.com|alias1,alias2,alias3"
|
||||
- "username2@my-domain.com|alias4"
|
||||
volumes:
|
||||
- ./spamassassin:/tmp/spamassassin/:ro
|
||||
- ./postfix:/tmp/postfix/:ro
|
||||
|
|
1
postfix/accounts.cf
Normal file
1
postfix/accounts.cf
Normal file
|
@ -0,0 +1 @@
|
|||
user@domain.tld|mypassword|alias1,alias2
|
1
spamassassin/rules.cf
Normal file
1
spamassassin/rules.cf
Normal file
|
@ -0,0 +1 @@
|
|||
# Place you custom Spamassasin rules here
|
|
@ -1,17 +1,20 @@
|
|||
#!/bin/sh
|
||||
|
||||
echo "Regenerating 'vmailbox' for given users"
|
||||
|
||||
echo "Regenerating postfix 'vmailbox' and 'virtual' for given users"
|
||||
# rm /etc/postfix/virtual
|
||||
# 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 $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 aliases
|
||||
do
|
||||
|
||||
# Setting variables for better readability
|
||||
user=$(echo ${login} | cut -d @ -f1)
|
||||
domain=$(echo ${login} | cut -d @ -f2)
|
||||
|
||||
# Let's go!
|
||||
echo "user '${user}' for domain '${domain}' with password '${pass}'"
|
||||
echo "user '${user}' for domain '${domain}' with password '********'"
|
||||
echo "${login} ${domain}/${user}/" >> /etc/postfix/vmailbox
|
||||
userdb ${login} set uid=5000 gid=5000 home=/var/mail/${domain}/${user} mail=/var/mail/${domain}/${user}
|
||||
echo "${pass}" | userdbpw -md5 | userdb ${login} set systempw
|
||||
|
@ -20,28 +23,20 @@ do
|
|||
maildirmake /var/mail/${domain}/${user}
|
||||
echo ${domain} >> /tmp/vhost.tmp
|
||||
|
||||
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
|
||||
# Aliases
|
||||
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
|
||||
rm /tmp/docker_mail_aliases
|
||||
|
||||
done < /tmp/postfix/accounts.cf
|
||||
makeuserdb
|
||||
|
||||
echo "Postfix configurations"
|
||||
postmap /etc/postfix/vmailbox
|
||||
touch /etc/postfix/virtual && postmap /etc/postfix/virtual
|
||||
postmap /etc/postfix/virtual
|
||||
sed -i -r 's/DOCKER_MAIL_DOMAIN/'"$docker_mail_domain"'/g' /etc/postfix/main.cf
|
||||
cat /tmp/vhost.tmp | sort | uniq >> /etc/postfix/vhost && rm /tmp/vhost.tmp
|
||||
|
||||
|
@ -57,6 +52,7 @@ echo "required_hits 5.0" >> /etc/mail/spamassassin/local.cf
|
|||
echo "report_safe 0" >> /etc/mail/spamassassin/local.cf
|
||||
echo "required_score 5" >> /etc/mail/spamassassin/local.cf
|
||||
echo "rewrite_header Subject ***SPAM***" >> /etc/mail/spamassassin/local.cf
|
||||
cp /tmp/spamassassin/rules.cf /etc/spamassassin/
|
||||
|
||||
echo "Starting daemons"
|
||||
/etc/init.d/rsyslog start
|
||||
|
|
Loading…
Reference in a new issue