debian postfix with amavis spam & virus scanner. can be used as gateway, smarthost etc. [x86 + arm]
50K+
maintained by ServerContainers
You'll find all images tagged like d11.2-p3.5.6-1_b1 which means d<debian version>-p<postfix version (with some esacped chars)>.
This way you can pin your installation/configuration to a certian version. or easily roll back if you experience any problems
(don't forget to open a issue in that case ;D).
The latest version will be updated/released after I managed to test a new pinned version in my production environment.
This way I can easily find and fix bugs without affecting any users. It will result in a way more stable container.
bullseyeThis Dockerfile (available as servercontainers/mail-gateway) gives you a Postfix Configured for the following scenarios.
For Configuration of the Server you use environment Variables and volume files.
It's based on the debian:bullseye Image
View in Docker Hub servercontainers/mail-gateway
View in GitHub ServerContainers/mail-gateway
This container is not meant to be used as a mail server which stores mails and handles mailboxes. Just put this container in between the outside world and your mailbox handeling mail server. Take a look at ServerContainers/mail-box for a mail server with mailbox/imap handling.
OFFICIAL ENVIRONMENT VARIABLES
MAIL_FQDN
POSTFIX_SMTPD_BANNER
AUTO_TRUST_NETWORKS
ADDITIONAL_MYNETWORKS
0.0.0.0/0 to make this an open relayMYNETWORKS
RELAYHOST
DISABLE_AMAVIS
DISABLE_VIRUS_CHECKS
DISABLE_SPAM_CHECKS
AMAVIS_SA_TAG_LEVEL_DEFLT
AMAVIS_SA_TAG2_LEVEL_DEFLT
AMAVIS_SA_KILL_LEVEL_DEFLT
POSTFIX_SSL_OUT_CERT
POSTFIX_SSL_OUT_KEY
POSTFIX_SSL_OUT_SECURITY_LEVEL
POSTFIX_SSL_IN_CERT
POSTFIX_SSL_IN_KEY
POSTFIX_SSL_IN_SECURITY_LEVEL
POSTFIX_SSL_IN_CERT_FINGERPRINTS
POSTFIX_QUEUE_LIFETIME_BOUNCE
POSTFIX_QUEUE_LIFETIME_MAX
POSTFIX_RELAY_DOMAINS
POSTFIX_MYDESTINATION
HIGH PRIORITY ENVIRONMENT VARIABLE
the following variable/s are only if you have some specific settings you need. They help you overwrite everything after the config was generated. If you can update your setting with the variables from above, it is strongly recommended to use them!
some characters might brake your configuration!
for example: to set mynetworks_style = subnet just add a environment variable POSTFIX_RAW_CONFIG_MYNETWORKS_STYLE=subnet
This Server enables you to use DKIM for multiple Domains by default.
To use it just add your domains to the DKIM_DOMAINS environment variable. DKIM_DOMAINS: example.com myotherdomain.tld
and make sure the folder /etc/postfix/additional/opendkim is available from within the container (/etc/postfix/additional is a volume).
After that the DKIM Keys will be generated automatically if necessary. All DKIM Public Informations for your DNS Servers will be printed to the Docker Logs.
So you start the container wait for the Public Keys to appear in the Docker logs and add them to the Domains in your DNS System.
You don't need the next steps, but they are great to understand how DKIM works
If you want to know how the multi domain handeling is done just take a look at the containers github repository
To generate DKIM keys you'll need the opendkim tools
$ apt-get install opendkim-tools
This generates a new certificate for @example.com with selector -s mail. If you want to Test DKIM first, add -t argument which stands for test-mode.
$ opendkim-genkey -s mail -d example.com
Just put the file mail.private as dkim.key inside the dkim directory you'll later link into the container using -v.
The mail.txt should be imported into the DNS System. Add a new TXT-Record for mail._domainkey [selector._domainkey]. And add as value the String starting "v=DKIM1;..." from the mail.txt file.
Example:
$ cat mail.txt
mail._domainkey IN TXT ( "v=DKIM1; k=rsa; "
"p=MIGfMA0GCSqGSIb3DQEBAQUAA4GNADCBiQKBgQDcUp8Q1sbxgnR2iL7w+TOHN1IR6PzAP3vmUoPfeN07NGfWo8Wzxyn+hqqnC+mbPOW4ZDoAiu5dvpPsCt1RQalwBw/iPlB/8ScTlPGRpsTLo4ruCDL+yVkw32/UhvCL8vbZxM/Q7ELjO6AqRRW/KuCvbd5gNRYGeyjWd+UQAfmBJQIDAQAB" ) ; ----- DKIM key mail for example.com
You need to put this line in your example.com DNS config zone:
mail._domainkey IN TXT "v=DKIM1; k=rsa; p=MIGfMA0GCSqGSIb3DQEBAQUAA4GNADCBiQKBgQDcUp8Q1sbxgnR2iL7w+TOHN1IR6PzAP3vmUoPfeN07NGfWo8Wzxyn+hqqnC+mbPOW4ZDoAiu5dvpPsCt1RQalwBw/iPlB/8ScTlPGRpsTLo4ruCDL+yVkw32/UhvCL8vbZxM/Q7ELjO6AqRRW/KuCvbd5gNRYGeyjWd+UQAfmBJQIDAQAB"
Thats all you need for DKIM
Check DNS config:
$ host -t TXT mail._domainkey.example.com
mail._domainkey.example.com descriptive text "v=DKIM1\; k=rsa\; p=MIGfMA0GCSqGSIb3DQEBAQUAA4GNADCBiQKBgQDcUp8Q1sbxgnR2iL7w+TOHN1IR6PzAP3vmUoPfeN07NGfWo8Wzxyn+hqqnC+mbPOW4ZDoAiu5dvpPsCt1RQalwBw/iPlB/8ScTlPGRpsTLo4ruCDL+yVkw32/UhvCL8vbZxM/Q7ELjO6AqRRW/KuCvbd5gNRYGeyjWd+UQAfmBJQIDAQAB"
Please note, that the Common Name (CN) is important and should be the FQDN to the secured server:
openssl req -x509 -newkey rsa:4086 \
-keyout key.pem -out cert.pem \
-days 3650 -nodes -sha256
openssl x509 -noout -fingerprint -in cert.pem
AA:BB:CC:DD:EE:FF:12:34:56:67:2E:FB:3F:34:99:90:AB:CD:EF:4C trusted.mailserver.example.tld
# generate CA cert & key
openssl genrsa -out rootCA.key 4096
openssl req -x509 -new -nodes -key rootCA.key -sha256 -days 1024 -out rootCA.pem
# create csr
openssl genrsa -out device.key 4096
openssl req -new -key device.key -out device.csr
# sign csr with CA
openssl x509 -req -in device.csr -CA rootCA.pem -CAkey rootCA.key -CAcreateserial -out device.crt -days 500 -sha256
##### TLS settings ######
### outgoing connections ###
# smtp_tls_security_level=encrypt # for secure connections only
smtp_tls_security_level=$POSTFIX_SSL_OUT_SECURITY_LEVEL
smtp_tls_cert_file=$POSTFIX_SSL_OUT_CERT
smtp_tls_key_file=$POSTFIX_SSL_OUT_KEY
smtp_tls_exclude_ciphers = aNULL, DES, RC4, MD5, 3DES
smtp_tls_mandatory_exclude_ciphers = aNULL, DES, RC4, MD5, 3DES
smtp_tls_mandatory_ciphers=medium
smtp_tls_protocols = TLSv1.3 TLSv1.2, !TLSv1.1, !TLSv1, !SSLv2, !SSLv3
smtp_tls_mandatory_protocols = TLSv1.3 TLSv1.2, !TLSv1.1, !TLSv1, !SSLv2, !SSLv3
smtp_tls_session_cache_database = btree:\${data_directory}/smtp_scache
smtp_tls_loglevel = 1
### incoming connections ###
# smtpd_tls_security_level=encrypt # for secure connections only
smtpd_tls_security_level=$POSTFIX_SSL_IN_SECURITY_LEVEL
smtpd_tls_cert_file=$POSTFIX_SSL_IN_CERT
smtpd_tls_key_file=$POSTFIX_SSL_IN_KEY
smtpd_tls_exclude_ciphers = aNULL, DES, RC4, MD5, 3DES
smtpd_tls_mandatory_exclude_ciphers = aNULL, DES, RC4, MD5, 3DES
smtpd_tls_mandatory_ciphers=high
smtpd_tls_protocols = TLSv1.3 TLSv1.2, !TLSv1.1, !TLSv1, !SSLv2, !SSLv3
smtpd_tls_mandatory_protocols = TLSv1.3 TLSv1.2, !TLSv1.1, !TLSv1, !SSLv2, !SSLv3
smtpd_tls_session_cache_database = btree:\${data_directory}/smtpd_scache
smtpd_tls_loglevel = 1
postconf -e smtpd_tls_ask_ccert=yes
postconf -e smtpd_tls_CAfile=/etc/postfix/tls/rootCA.crt
postconf -e smtpd_recipient_restrictions=permit_mynetworks,permit_tls_all_clientcerts,reject_unauth_destination
Content type
Image
Digest
sha256:1596b8fd5…
Size
255.1 MB
Last updated
2 months ago
docker pull servercontainers/mail-gateway