#!/bin/bash set -e postconf maillog_file=/dev/stdout postconf alias_maps=hash:/etc/aliases {{- if getenv "BIFF" }} postconf biff='{{ getenv "BIFF" }}' {{- end }} {{- if getenv "MESSAGE_SIZE_LIMIT" }} postconf message_size_limit='{{ getenv "MESSAGE_SIZE_LIMIT" }}' {{- end }} {{- if getenv "MYDESTINATION" }} postconf mydestination='{{ getenv "MYDESTINATION" }}' {{- end }} {{- if getenv "MYDOMAIN" }} postconf mydomain='{{ getenv "MYDOMAIN" }}' {{- end }} {{- if getenv "MYHOSTNAME" }} postconf myhostname='{{ getenv "MYHOSTNAME" }}' {{- end }} {{- if getenv "MYNETWORKS" }} postconf mynetworks='{{ getenv "MYNETWORKS" }}' {{- end }} {{- if getenv "MYNETWORKS_STYLE" }} postconf mynetworks_style='{{ getenv "MYNETWORKS_STYLE" }}' {{- end }} {{- if getenv "PROPAGATE_UNMATCHED_EXTENSIONS" }} postconf propagate_unmatched_extensions='{{ getenv "PROPAGATE_UNMATCHED_EXTENSIONS" }}' {{- end }} {{- if getenv "RECIPIENT_DELIMITER" }} postconf recipient_delimiter='{{ getenv "RECIPIENT_DELIMITER" }}' {{- end }} {{- if getenv "SMTP_TLS_SECURITY_LEVEL" }} postconf smtp_tls_security_level='{{ getenv "SMTP_TLS_SECURITY_LEVEL" }}' {{- end }} {{- if getenv "SMTPD_CLIENT_RESTRICTIONS" }} postconf smtpd_client_restrictions='{{ getenv "SMTPD_CLIENT_RESTRICTIONS" }}' {{- end }} {{- if getenv "SMTPD_DATA_RESTRICTIONS" }} postconf smtpd_data_restrictions='{{ getenv "SMTPD_DATA_RESTRICTIONS" }}' {{- end }} {{- if getenv "SMTPD_HELO_REQUIRED" }} postconf smtpd_helo_required='{{ getenv "SMTPD_HELO_REQUIRED" }}' {{- end }} {{- if getenv "SMTPD_HELO_RESTRICTIONS" }} postconf smtpd_helo_restrictions='{{ getenv "SMTPD_HELO_RESTRICTIONS" }}' {{- end }} {{- if getenv "SMTPD_RECIPIENT_RESTRICTIONS" }} postconf smtpd_recipient_restrictions='{{ getenv "SMTPD_RECIPIENT_RESTRICTIONS" }}' {{- end }} {{- if getenv "SMTPD_RELAY_RESTRICTIONS" }} postconf smtpd_relay_restrictions='{{ getenv "SMTPD_RELAY_RESTRICTIONS" }}' {{- end }} {{- if getenv "SMTPD_SASL_AUTH_ENABLE" }} postconf smtpd_sasl_auth_enable='{{ getenv "SMTPD_SASL_AUTH_ENABLE" }}' {{- end }} {{- if getenv "SMTPD_SASL_PATH" }} postconf smtpd_sasl_path='{{ getenv "SMTPD_SASL_PATH" }}' {{- end }} {{- if getenv "SMTPD_SASL_TYPE" }} postconf smtpd_sasl_type='{{ getenv "SMTPD_SASL_TYPE" }}' {{- end }} {{- if getenv "SMTPD_TLS_AUTH_ONLY" }} postconf smtpd_tls_auth_only='{{ getenv "SMTPD_TLS_AUTH_ONLY" }}' {{- end }} {{- if getenv "SMTPD_TLS_CERT_FILE" }} postconf smtpd_tls_cert_file='{{ getenv "SMTPD_TLS_CERT_FILE" }}' {{- end }} {{- if getenv "SMTPD_TLS_KEY_FILE" }} postconf smtpd_tls_key_file='{{ getenv "SMTPD_TLS_KEY_FILE" }}' {{- end }} {{- if getenv "SMTPD_TLS_SECURITY_LEVEL" }} postconf smtpd_tls_security_level='{{ getenv "SMTPD_TLS_SECURITY_LEVEL" }}' {{- end }} {{- if getenv "SMTPD_TLS_SESSION_CACHE_DATABASE" }} postconf smtpd_tls_session_cache_database='{{ getenv "SMTPD_TLS_SESSION_CACHE_DATABASE" }}' {{- end }} {{- if getenv "SMTPUTF8_ENABLE" }} postconf smtputf8_enable='{{ getenv "SMTPUTF8_ENABLE" }}' {{- end }} {{- if getenv "VIRTUAL_ALIAS_MAPS" }} postconf virtual_alias_maps='{{ getenv "VIRTUAL_ALIAS_MAPS" }}' {{- end }} {{- if getenv "VIRTUAL_MAILBOX_DOMAINS" }} postconf virtual_mailbox_domains='{{ getenv "VIRTUAL_MAILBOX_DOMAINS" }}' {{- end }} {{- if getenv "VIRTUAL_MAILBOX_MAPS" }} postconf virtual_mailbox_maps='{{ getenv "VIRTUAL_MAILBOX_MAPS" }}' {{- end }} {{- if getenv "VIRTUAL_TRANSPORT" }} postconf virtual_transport='{{ getenv "VIRTUAL_TRANSPORT" }}' {{- end }} postconf -M spamfilter/unix | grep -q spamfilter || { postconf -M spamfilter/unix="spamfilter unix - n n - - pipe" } postconf -F spamfilter/unix/private=- \ spamfilter/unix/unprivileged=n \ spamfilter/unix/chroot=n \ spamfilter/unix/wakeup=- \ spamfilter/unix/process_limit=- \ spamfilter/unix/command='pipe flags=Rq user=vmail argv=/usr/local/bin/spamfilter -oi -f ${sender} ${recipient}' # run postmap for all lookup tables postmap_all