Skip to content

Commit c8758da

Browse files
cursoragentjeboehm
andcommitted
feat: Enable Postfix Postscreen and configure Unbound DNS
Co-authored-by: j.boehm <[email protected]>
1 parent eb4b542 commit c8758da

File tree

2 files changed

+30
-0
lines changed

2 files changed

+30
-0
lines changed

target/mta/Dockerfile

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -67,6 +67,16 @@ RUN apk --no-cache add \
6767
postconf smtpd_soft_error_limit=3 && \
6868
postconf smtpd_hard_error_limit=5 && \
6969
newaliases && \
70+
# enable postscreen on port 25 and supporting services
71+
sed -i 's/^smtp\s\+inet\s\+n\s\+-\s\+y\s\+-\s\+-\s\+smtpd/smtp inet n - y - 1 postscreen/' /etc/postfix/master.cf && \
72+
printf '%s\n' \
73+
'smtpd pass - - y - - smtpd' \
74+
'dnsblog unix - - y - 0 dnsblog' \
75+
'tlsproxy unix - - y - 0 tlsproxy' \
76+
>> /etc/postfix/master.cf && \
77+
postconf postscreen_dnsbl_sites='bl.spamcop.net*2' && \
78+
postconf postscreen_dnsbl_threshold=2 && \
79+
postconf postscreen_dnsbl_action=enforce && \
7080
echo "submission inet n - n - - smtpd" >> /etc/postfix/master.cf && \
7181
echo " -o syslog_name=postfix/submission" >> /etc/postfix/master.cf && \
7282
echo " -o smtpd_tls_security_level=encrypt" >> /etc/postfix/master.cf && \

target/mta/rootfs/usr/local/bin/init.sh

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -39,3 +39,23 @@ dockerize \
3939
-template /etc/postfix/mysql-recipient-access.cf.templ:/etc/postfix/mysql-recipient-access.cf \
4040
-template /etc/postfix/mysql-email-submission.cf.templ:/etc/postfix/mysql-email-submission.cf \
4141
/bin/true
42+
43+
# Configure resolver for Postfix to use $UNBOUND_DNS_ADDRESS
44+
# Accept formats like "host:port" or "ip:port"; default port 53 if omitted
45+
if [ -n "${UNBOUND_DNS_ADDRESS}" ]; then
46+
UNBOUND_DNS_HOST=$(echo "${UNBOUND_DNS_ADDRESS}" | cut -d: -f1)
47+
UNBOUND_DNS_PORT=$(echo "${UNBOUND_DNS_ADDRESS}" | cut -s -d: -f2)
48+
if [ -z "${UNBOUND_DNS_PORT}" ]; then
49+
UNBOUND_DNS_PORT=53
50+
fi
51+
52+
# Resolve hostname to IP if necessary
53+
UNBOUND_DNS_IP=$(getent hosts "${UNBOUND_DNS_HOST}" | awk '{print $1}' | head -n1)
54+
if [ -z "${UNBOUND_DNS_IP}" ]; then
55+
UNBOUND_DNS_IP=${UNBOUND_DNS_HOST}
56+
fi
57+
58+
mkdir -p /var/spool/postfix/etc
59+
echo "nameserver ${UNBOUND_DNS_IP}" > /var/spool/postfix/etc/resolv.conf
60+
# glibc resolv.conf does not support custom port; rely on Unbound standard port 53
61+
fi

0 commit comments

Comments
 (0)