diff --git a/Dockerfile b/Dockerfile index f6ce004..314fb09 100644 --- a/Dockerfile +++ b/Dockerfile @@ -54,6 +54,8 @@ ENV NON_SMTPD_MILTERS="\$smtpd_milters" ENV MILTER_DEFAULT_ACTION=accept ENV INTERNAL_MAIL_FILTER_CLASSES=bounce ENV BOGOFILTER_ENABLE="yes" +ENV BOGOFILTER_HAM_CUTOFF="0.499999" +ENV BOGOFILTER_SPAM_CUTOFF="0.499999" # TODO: template access lists @@ -106,7 +108,7 @@ RUN echo "_dev_null: /dev/null" > /etc/aliases \ scache/unix/chroot=n ADD confd /etc/confd/ -ADD postmap_all spamfilter /usr/local/bin/ +ADD postmap_all /usr/local/bin/ VOLUME ["/ssl","/var/spool/postfix"] EXPOSE 25/tcp 587/tcp diff --git a/confd/conf.d/spamfilter.toml b/confd/conf.d/spamfilter.toml new file mode 100644 index 0000000..38ce3c4 --- /dev/null +++ b/confd/conf.d/spamfilter.toml @@ -0,0 +1,8 @@ +[template] +src = "spamfilter.tmpl" +dest = "/usr/local/bin/spamfilter" +mode = "0755" +keys = [ +"/bogofilter/ham/cutoff", +"/bogofilter/spam/cutoff", +] diff --git a/confd/templates/spamfilter.tmpl b/confd/templates/spamfilter.tmpl new file mode 100755 index 0000000..4320f65 --- /dev/null +++ b/confd/templates/spamfilter.tmpl @@ -0,0 +1,6 @@ +#!/bin/bash + +# pass mail through spam filter Bogofilter +# arguments are passed on to sendmail + +/usr/bin/bogofilter -d /vmail/bogofilter -p {{ with getv "/bogofilter/ham/cutoff" }}--ham-cutoff {{.}}{{ end }} {{ with getv "/bogofilter/spam/cutoff" }}--spam-cutoff {{.}}{{ end }} | /usr/sbin/sendmail "$@" diff --git a/postmap_all b/postmap_all index 94dfb13..68fe2dd 100755 --- a/postmap_all +++ b/postmap_all @@ -3,14 +3,14 @@ # run postmap on all configured lookup tables postconf -h \ - postscreen_access_list \ - postscreen_dnsbl_reply_map \ - smtp_sasl_password_maps \ - smtpd_client_restrictions \ - smtpd_helo_restrictions \ - smtpd_recipient_restrictions \ - virtual_alias_maps \ - virtual_mailbox_maps \ + postscreen_access_list \ + postscreen_dnsbl_reply_map \ + smtp_sasl_password_maps \ + smtpd_client_restrictions \ + smtpd_helo_restrictions \ + smtpd_recipient_restrictions \ + virtual_alias_maps \ + virtual_mailbox_maps \ | sed "s/,/\n/g" | sed "s/ /\n/g" | sort | uniq \ | egrep '(hash):' \ | xargs -n1 postmap diff --git a/spamfilter b/spamfilter deleted file mode 100755 index be63f8e..0000000 --- a/spamfilter +++ /dev/null @@ -1,6 +0,0 @@ -#!/bin/bash - -# pass mail through spam filter Bogofilter -# arguments are passed on to sendmail - -/usr/bin/bogofilter -d /vmail/bogofilter -p | /usr/sbin/sendmail "$@"