diff --git a/LICENSE b/LICENSE index a67f2b5..5fa45c2 100644 --- a/LICENSE +++ b/LICENSE @@ -1,6 +1,6 @@ The MIT License (MIT) -Copyright (c) 2014 Benno Evers +Copyright (c) 2015 Valentin Arkhipov Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal diff --git a/config/dovecot.auth b/config/dovecot.auth deleted file mode 100644 index fbff5fe..0000000 --- a/config/dovecot.auth +++ /dev/null @@ -1,14 +0,0 @@ -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 -} - - diff --git a/config/dovecot.master b/config/dovecot.master deleted file mode 100644 index 226be08..0000000 --- a/config/dovecot.master +++ /dev/null @@ -1,34 +0,0 @@ -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 { -} diff --git a/Dockerfile b/email_core/Dockerfile similarity index 66% rename from Dockerfile rename to email_core/Dockerfile index eebd014..abe5d4f 100644 --- a/Dockerfile +++ b/email_core/Dockerfile @@ -8,7 +8,6 @@ RUN apt-get update && apt-get install -y \ ssl-cert \ postfix \ dovecot-imapd \ - opendkim && \ apt-get clean && \ rm -rf /var/lib/apt/lists/* /tmp/* /var/tmp/* @@ -19,8 +18,8 @@ RUN cat /etc/postfix/master-additional.cf >> /etc/postfix/master.cf # configure settings script VOLUME ["/mail_settings"] -COPY process_settings /process_settings -RUN chmod 755 /process_settings +COPY boot /boot +RUN chmod 755 /boot # add user vmail who own all mail folders VOLUME ["/vmail"] @@ -34,12 +33,9 @@ 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 -# add verbose logging -#ADD ./config/dovecot.logging /etc/dovecot/conf.d/10-logging.conf + +# Uncomment to add verbose logging +# ADD ./config/dovecot.logging /etc/dovecot/conf.d/10-logging.conf EXPOSE 25 143 587 -# todo: enable port 587 for outgoing mail, separate ports 25 and 587 -# http://www.synology-wiki.de/index.php/Zusaetzliche_Ports_fuer_Postfix - -# start necessary services for operation (dovecot -F starts dovecot in the foreground to prevent container exit) -ENTRYPOINT /process_settings; service rsyslog start; service opendkim start; service postfix start; dovecot -F +ENTRYPOINT /boot; service rsyslog start; service postfix start; dovecot -F diff --git a/process_settings b/email_core/boot similarity index 83% rename from process_settings rename to email_core/boot index bc855d1..20fd09a 100644 --- a/process_settings +++ b/email_core/boot @@ -3,21 +3,15 @@ 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 + 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 + cp /etc/ssl/certs/ssl-cert-snakeoil.pem /mail_settings/ssl-cert-snakeoil.pem fi -# Copy OpenDKIM config -cp /mail_settings/opendkim.conf /etc/opendkim.conf -cp /mail_settings/mail.private /etc/dkim.key -chown opendkim:opendkim /etc/dkim.key -chmod 600 /etc/dkim.key - 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 @@ -27,13 +21,13 @@ fi cp /mail_settings/aliases /etc/postfix/virtual cp /mail_settings/domains /etc/postfix/virtual-mailbox-domains -# todo: this could probably be done in one line +# 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 the ownership of his files +# give postfix ownership of its files chown -R postfix:postfix /etc/postfix # map virtual aliases and user/filesystem mappings diff --git a/email_core/config/dovecot.auth b/email_core/config/dovecot.auth new file mode 100644 index 0000000..61b6bd7 --- /dev/null +++ b/email_core/config/dovecot.auth @@ -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 +} diff --git a/config/dovecot.imap b/email_core/config/dovecot.imap similarity index 100% rename from config/dovecot.imap rename to email_core/config/dovecot.imap diff --git a/config/dovecot.lda b/email_core/config/dovecot.lda similarity index 100% rename from config/dovecot.lda rename to email_core/config/dovecot.lda diff --git a/config/dovecot.logging b/email_core/config/dovecot.logging similarity index 100% rename from config/dovecot.logging rename to email_core/config/dovecot.logging diff --git a/config/dovecot.mail b/email_core/config/dovecot.mail similarity index 98% rename from config/dovecot.mail rename to email_core/config/dovecot.mail index aa09e2b..5909b51 100644 --- a/config/dovecot.mail +++ b/email_core/config/dovecot.mail @@ -16,4 +16,4 @@ namespace inbox { auto = subscribe # autocreate and autosubscribe the Sent mailbox special_use = \Sent } - } +} diff --git a/email_core/config/dovecot.master b/email_core/config/dovecot.master new file mode 100644 index 0000000..2890241 --- /dev/null +++ b/email_core/config/dovecot.master @@ -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 { +} diff --git a/config/dovecot.ssl b/email_core/config/dovecot.ssl similarity index 100% rename from config/dovecot.ssl rename to email_core/config/dovecot.ssl diff --git a/config/example/aliases b/email_core/config/example/aliases similarity index 100% rename from config/example/aliases rename to email_core/config/example/aliases diff --git a/config/example/domains b/email_core/config/example/domains similarity index 100% rename from config/example/domains rename to email_core/config/example/domains diff --git a/config/example/myhostname b/email_core/config/example/myhostname similarity index 100% rename from config/example/myhostname rename to email_core/config/example/myhostname diff --git a/config/example/passwords b/email_core/config/example/passwords similarity index 100% rename from config/example/passwords rename to email_core/config/example/passwords diff --git a/config/postfix.main.cf b/email_core/config/postfix.main.cf similarity index 95% rename from config/postfix.main.cf rename to email_core/config/postfix.main.cf index ace7970..36f7f42 100644 --- a/config/postfix.main.cf +++ b/email_core/config/postfix.main.cf @@ -1,12 +1,11 @@ # 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 (Ubuntu) +smtpd_banner = $myhostname ESMTP $mail_name biff = no # appending .domain is the MUA's job. @@ -27,12 +26,11 @@ 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 = +relayhost = mynetworks = 127.0.0.0/8 [::ffff:127.0.0.0]/104 [::1]/128 mailbox_size_limit = 0 recipient_delimiter = + @@ -76,4 +74,4 @@ smtpd_sasl_path = private/auth milter_default_action = accept milter_protocol = 2 smtpd_milters = inet:localhost:8891 -non_smtpd_milters = inet:localhost:8891 \ No newline at end of file +non_smtpd_milters = inet:localhost:8891 diff --git a/config/postfix.master.cf.append b/email_core/config/postfix.master.cf.append similarity index 99% rename from config/postfix.master.cf.append rename to email_core/config/postfix.master.cf.append index 21efaeb..b0dd33a 100644 --- a/config/postfix.master.cf.append +++ b/email_core/config/postfix.master.cf.append @@ -12,4 +12,4 @@ submission inet n - n - - smtpd -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 \ No newline at end of file + -o smtpd_recipient_restrictions=permit_sasl_authenticated,reject diff --git a/opendkim/Dockerfile b/opendkim/Dockerfile new file mode 100644 index 0000000..4824c0c --- /dev/null +++ b/opendkim/Dockerfile @@ -0,0 +1,18 @@ +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 \ + opendkim && \ + apt-get clean && \ + rm -rf /var/lib/apt/lists/* /tmp/* /var/tmp/* + +# configure settings script +VOLUME ["/mail_settings"] +COPY boot /boot +RUN chmod 755 /boot + +# start necessary services for operation (dovecot -F starts dovecot in the foreground to prevent container exit) +ENTRYPOINT /boot; service rsyslog start; opendkim -f diff --git a/opendkim/boot b/opendkim/boot new file mode 100644 index 0000000..8011a8c --- /dev/null +++ b/opendkim/boot @@ -0,0 +1,5 @@ +# Copy OpenDKIM config +cp /mail_settings/opendkim.conf /etc/opendkim.conf +cp /mail_settings/mail.private /etc/dkim.key +chown opendkim:opendkim /etc/dkim.key +chmod 600 /etc/dkim.key diff --git a/config/example/opendkim.conf b/opendkim/config/example/opendkim.conf similarity index 100% rename from config/example/opendkim.conf rename to opendkim/config/example/opendkim.conf