Major move around
This commit is contained in:
41
email_core/Dockerfile
Normal file
41
email_core/Dockerfile
Normal file
@@ -0,0 +1,41 @@
|
||||
FROM ubuntu:14.10
|
||||
|
||||
ENV DEBIAN_FRONTEND noninteractive
|
||||
RUN locale-gen en_GB en_GB.UTF-8 && dpkg-reconfigure locales
|
||||
|
||||
# Prerequisites
|
||||
RUN apt-get update && apt-get install -y \
|
||||
ssl-cert \
|
||||
postfix \
|
||||
dovecot-imapd \
|
||||
apt-get clean && \
|
||||
rm -rf /var/lib/apt/lists/* /tmp/* /var/tmp/*
|
||||
|
||||
# postfix configuration
|
||||
ADD ./config/postfix.main.cf /etc/postfix/main.cf
|
||||
ADD ./config/postfix.master.cf.append /etc/postfix/master-additional.cf
|
||||
RUN cat /etc/postfix/master-additional.cf >> /etc/postfix/master.cf
|
||||
|
||||
# configure settings script
|
||||
VOLUME ["/mail_settings"]
|
||||
COPY boot /boot
|
||||
RUN chmod 755 /boot
|
||||
|
||||
# add user vmail who own all mail folders
|
||||
VOLUME ["/vmail"]
|
||||
RUN groupadd -g 5000 vmail
|
||||
RUN useradd -g vmail -u 5000 vmail -d /vmail -m
|
||||
|
||||
# dovecot configuration
|
||||
ADD ./config/dovecot.mail /etc/dovecot/conf.d/10-mail.conf
|
||||
ADD ./config/dovecot.ssl /etc/dovecot/conf.d/10-ssl.conf
|
||||
ADD ./config/dovecot.auth /etc/dovecot/conf.d/10-auth.conf
|
||||
ADD ./config/dovecot.master /etc/dovecot/conf.d/10-master.conf
|
||||
ADD ./config/dovecot.lda /etc/dovecot/conf.d/15-lda.conf
|
||||
ADD ./config/dovecot.imap /etc/dovecot/conf.d/20-imap.conf
|
||||
|
||||
# Uncomment to add verbose logging
|
||||
# ADD ./config/dovecot.logging /etc/dovecot/conf.d/10-logging.conf
|
||||
|
||||
EXPOSE 25 143 587
|
||||
ENTRYPOINT /boot; service rsyslog start; service postfix start; dovecot -F
|
||||
43
email_core/boot
Normal file
43
email_core/boot
Normal file
@@ -0,0 +1,43 @@
|
||||
# Check if we have SSL certificates in config, otherwise copy it there
|
||||
# First the key file
|
||||
if [ -f /mail_settings/ssl-cert-snakeoil.key ]; then
|
||||
cp /mail_settings/ssl-cert-snakeoil.key /etc/ssl/private/ssl-cert-snakeoil.key
|
||||
else
|
||||
cp /etc/ssl/private/ssl-cert-snakeoil.key /mail_settings/ssl-cert-snakeoil.key
|
||||
fi
|
||||
# Then the pem file
|
||||
if [ -f /mail_settings/ssl-cert-snakeoil.pem ]; then
|
||||
cp /mail_settings/ssl-cert-snakeoil.pem /etc/ssl/certs/ssl-cert-snakeoil.pem
|
||||
else
|
||||
cp /etc/ssl/certs/ssl-cert-snakeoil.pem /mail_settings/ssl-cert-snakeoil.pem
|
||||
fi
|
||||
|
||||
if [ -f /mail_settings/myhostname ]; then
|
||||
sed -i -e "s/myhostname = localhost/myhostname = $(sed 's:/:\\/:g' /mail_settings/myhostname)/" /etc/postfix/main.cf
|
||||
echo $(sed 's:/:\\/:g' /mail_settings/myhostname) > /etc/mailname
|
||||
fi
|
||||
|
||||
# configure mail delivery to dovecot
|
||||
cp /mail_settings/aliases /etc/postfix/virtual
|
||||
cp /mail_settings/domains /etc/postfix/virtual-mailbox-domains
|
||||
|
||||
# parse mailbox settings
|
||||
mkdir /etc/postfix/tmp
|
||||
awk < /etc/postfix/virtual '{ print $2 }' > /etc/postfix/tmp/virtual-receivers
|
||||
sed -r 's,(.+)@(.+),\2/\1/,' /etc/postfix/tmp/virtual-receivers > /etc/postfix/tmp/virtual-receiver-folders
|
||||
paste /etc/postfix/tmp/virtual-receivers /etc/postfix/tmp/virtual-receiver-folders > /etc/postfix/virtual-mailbox-maps
|
||||
|
||||
# give postfix ownership of its files
|
||||
chown -R postfix:postfix /etc/postfix
|
||||
|
||||
# map virtual aliases and user/filesystem mappings
|
||||
postmap /etc/postfix/virtual
|
||||
postmap /etc/postfix/virtual-mailbox-maps
|
||||
chown -R postfix:postfix /etc/postfix
|
||||
|
||||
# make user vmail own all mail folders
|
||||
chown -R vmail:vmail /vmail
|
||||
chmod u+w /vmail
|
||||
|
||||
# Add password file
|
||||
cp /mail_settings/passwords /etc/dovecot/passwd
|
||||
11
email_core/config/dovecot.auth
Normal file
11
email_core/config/dovecot.auth
Normal file
@@ -0,0 +1,11 @@
|
||||
auth_mechanisms = plain login
|
||||
|
||||
passdb {
|
||||
driver = passwd-file
|
||||
args = /etc/dovecot/passwd
|
||||
}
|
||||
|
||||
userdb {
|
||||
driver = static
|
||||
args = uid=vmail gid=vmail home=/vmail/%d/%n allow_all_users=yes
|
||||
}
|
||||
3
email_core/config/dovecot.imap
Normal file
3
email_core/config/dovecot.imap
Normal file
@@ -0,0 +1,3 @@
|
||||
protocol imap {
|
||||
imap_client_workarounds = tb-extra-mailbox-sep
|
||||
}
|
||||
5
email_core/config/dovecot.lda
Normal file
5
email_core/config/dovecot.lda
Normal file
@@ -0,0 +1,5 @@
|
||||
protocol lda {
|
||||
hostname = mail.docker.container
|
||||
postmaster_address = postmaster@mail.docker.container
|
||||
mail_plugin_dir = /usr/lib/dovecot/modules/lda
|
||||
}
|
||||
2
email_core/config/dovecot.logging
Normal file
2
email_core/config/dovecot.logging
Normal file
@@ -0,0 +1,2 @@
|
||||
auth_verbose = yes
|
||||
auth_debug = yes
|
||||
19
email_core/config/dovecot.mail
Normal file
19
email_core/config/dovecot.mail
Normal file
@@ -0,0 +1,19 @@
|
||||
mail_location = maildir:/vmail/%d/%n:LAYOUT=fs
|
||||
|
||||
namespace inbox {
|
||||
inbox = yes
|
||||
|
||||
# set these to autocreate or else thunderbird will complain
|
||||
mailbox Trash {
|
||||
auto = create
|
||||
special_use = \Trash
|
||||
}
|
||||
mailbox Drafts {
|
||||
auto = subscribe
|
||||
special_use = \Drafts
|
||||
}
|
||||
mailbox Sent {
|
||||
auto = subscribe # autocreate and autosubscribe the Sent mailbox
|
||||
special_use = \Sent
|
||||
}
|
||||
}
|
||||
33
email_core/config/dovecot.master
Normal file
33
email_core/config/dovecot.master
Normal file
@@ -0,0 +1,33 @@
|
||||
service imap-login {
|
||||
inet_listener imap {
|
||||
|
||||
}
|
||||
|
||||
#disable imaps since we use TLS connections through the standard imap
|
||||
inet_listener imaps {
|
||||
port = 0
|
||||
}
|
||||
}
|
||||
|
||||
service imap {
|
||||
}
|
||||
|
||||
# not sure if this is needed
|
||||
service lmtp {
|
||||
unix_listener /var/spool/postfix/private/dovecot-lmtp {
|
||||
group = vmail
|
||||
mode = 0660
|
||||
user = postfix
|
||||
}
|
||||
}
|
||||
|
||||
service auth {
|
||||
unix_listener /var/spool/postfix/private/auth {
|
||||
mode = 0660
|
||||
user = postfix
|
||||
group = vmail
|
||||
}
|
||||
}
|
||||
|
||||
service auth-worker {
|
||||
}
|
||||
5
email_core/config/dovecot.ssl
Normal file
5
email_core/config/dovecot.ssl
Normal file
@@ -0,0 +1,5 @@
|
||||
ssl = required
|
||||
disable_plaintext_auth = yes
|
||||
ssl_cert = </etc/dovecot/dovecot.pem
|
||||
ssl_key = </etc/dovecot/private/dovecot.pem
|
||||
|
||||
2
email_core/config/example/aliases
Normal file
2
email_core/config/example/aliases
Normal file
@@ -0,0 +1,2 @@
|
||||
admin@example.org admin@example.org
|
||||
@example.org catch-all@example.org
|
||||
1
email_core/config/example/domains
Normal file
1
email_core/config/example/domains
Normal file
@@ -0,0 +1 @@
|
||||
example.org
|
||||
1
email_core/config/example/myhostname
Normal file
1
email_core/config/example/myhostname
Normal file
@@ -0,0 +1 @@
|
||||
localhost
|
||||
2
email_core/config/example/passwords
Normal file
2
email_core/config/example/passwords
Normal file
@@ -0,0 +1,2 @@
|
||||
catch-all@example.org:{PLAIN}password123
|
||||
admin@example.org:{SHA256-CRYPT}$5$3qaCC/fV65Adtfoy$O20EXoSOcgWKf5NyAZnXAtGPQoSgeYRjLm56M25.H12
|
||||
77
email_core/config/postfix.main.cf
Normal file
77
email_core/config/postfix.main.cf
Normal file
@@ -0,0 +1,77 @@
|
||||
# See /usr/share/postfix/main.cf.dist for a commented, more complete version
|
||||
|
||||
# Debian specific: Specifying a file name will cause the first
|
||||
# line of that file to be used as the name. The Debian default
|
||||
# is /etc/mailname.
|
||||
#myorigin = /etc/mailname
|
||||
|
||||
smtpd_banner = $myhostname ESMTP $mail_name
|
||||
biff = no
|
||||
|
||||
# appending .domain is the MUA's job.
|
||||
append_dot_mydomain = no
|
||||
|
||||
# Uncomment the next line to generate "delayed mail" warnings
|
||||
#delay_warning_time = 4h
|
||||
|
||||
readme_directory = no
|
||||
|
||||
# TLS parameters
|
||||
smtpd_tls_cert_file=/etc/ssl/certs/ssl-cert-snakeoil.pem
|
||||
smtpd_tls_key_file=/etc/ssl/private/ssl-cert-snakeoil.key
|
||||
smtpd_use_tls=yes
|
||||
smtpd_tls_session_cache_database = btree:${data_directory}/smtpd_scache
|
||||
smtp_tls_session_cache_database = btree:${data_directory}/smtp_scache
|
||||
|
||||
# See /usr/share/doc/postfix/TLS_README.gz in the postfix-doc package for
|
||||
# information on enabling SSL in the smtp client.
|
||||
|
||||
myhostname = localhost
|
||||
alias_maps = hash:/etc/aliases
|
||||
alias_database = hash:/etc/aliases
|
||||
mydestination = /etc/mailname, localhost.localdomain, localhost
|
||||
relayhost =
|
||||
mynetworks = 127.0.0.0/8 [::ffff:127.0.0.0]/104 [::1]/128
|
||||
mailbox_size_limit = 0
|
||||
recipient_delimiter = +
|
||||
|
||||
# SMTP configuration for incoming mail (port 25)
|
||||
# Outgoing mail (port 587) configuration is specified in master.cf
|
||||
|
||||
# allow all connections (since we want to receive mail from outside)
|
||||
smtpd_client_restrictions = permit
|
||||
|
||||
# Don't talk to mail systems that don't know their own hostname.
|
||||
# With Postfix < 2.3, specify reject_unknown_hostname.
|
||||
smtpd_helo_restrictions = permit
|
||||
|
||||
# Don't accept mail from domains that don't exist.
|
||||
smtpd_sender_restrictions = permit
|
||||
|
||||
# Only accept mail where this server is the final destination
|
||||
smtpd_relay_restrictions = permit_auth_destination, reject
|
||||
|
||||
# Mail thats not for us gets filtered out by smtpd_relay_restrictions
|
||||
# When the mail is for us, we just accept everything. (could add spam blocklists/user checking etc. here)
|
||||
smtpd_recipient_restrictions = permit
|
||||
|
||||
# Delivery to dovecot
|
||||
alias_maps = hash:/etc/aliases
|
||||
alias_database = hash:/etc/aliases
|
||||
virtual_alias_maps = hash:/etc/postfix/virtual
|
||||
virtual_mailbox_domains = /etc/postfix/virtual-mailbox-domains
|
||||
virtual_mailbox_maps = hash:/etc/postfix/virtual-mailbox-maps
|
||||
virtual_transport = dovecot
|
||||
dovecot_destination_recipient_limit = 1
|
||||
|
||||
# additional authentication settings
|
||||
smtpd_tls_auth_only = yes
|
||||
smtpd_sasl_auth_enable = yes
|
||||
smtpd_sasl_type = dovecot
|
||||
smtpd_sasl_path = private/auth
|
||||
|
||||
# DKIM
|
||||
milter_default_action = accept
|
||||
milter_protocol = 2
|
||||
smtpd_milters = inet:localhost:8891
|
||||
non_smtpd_milters = inet:localhost:8891
|
||||
15
email_core/config/postfix.master.cf.append
Normal file
15
email_core/config/postfix.master.cf.append
Normal file
@@ -0,0 +1,15 @@
|
||||
dovecot unix - n n - - pipe
|
||||
flags=DRhu user=vmail:vmail argv=/usr/lib/dovecot/deliver -f ${sender} -d ${recipient}
|
||||
|
||||
# we need to be permissive with the helo restrictions since the client can only
|
||||
# authenticate after HELO has been sent
|
||||
submission inet n - n - - smtpd
|
||||
-o smtpd_etrn_restrictions=reject
|
||||
-o smtpd_sasl_type=dovecot
|
||||
-o smtpd_sasl_path=private/auth
|
||||
-o smtpd_sasl_auth_enable=yes
|
||||
-o smtpd_helo_restrictions=permit
|
||||
-o smtpd_client_restrictions=permit_sasl_authenticated,reject
|
||||
-o smtpd_sender_restrictions=permit_sasl_authenticated,reject
|
||||
-o smtpd_relay_restrictions=permit_sasl_authenticated,reject
|
||||
-o smtpd_recipient_restrictions=permit_sasl_authenticated,reject
|
||||
Reference in New Issue
Block a user