====== Postfix ====== [[wpde>Postfix (Mail Transfer Agent)|Postfix]] ist ein Mail Transfer Agent für Unix und Unix-Derivate. Es wurde erschaffen, um eine kompatible Alternative zu Sendmail zu bieten. Bei der Entwicklung wurde insbesondere auf Sicherheitsaspekte geachtet. Postfix ist aber nicht nur sicher, sondern auch schnell und einfach zu administrieren. Zur Außenwelt verhält es sich wie Sendmail, aber im Inneren ist es komplett anders aufgebaut. Der Quellcode von Postfix steht unter der IBM Public License zur Verfügung. * [[Konfiguration von Postfix]] * [[Spamfilterung]] ===== Links ===== * [[http://www.postfix.org/|The Postfix Home Page]] * [[http://www.postfix.org/docs.html|Postfix Howtos and FAQs]] * [[http://www.postfix.org/postconf.5.html|man-pages von postconf]] * [[http://de.wikibooks.org/wiki/Postfix|wikibooks: Postfix]] * [[http://www.linuxjournal.com/article/9454|Anatomy of Postfix]] * [[http://www.hypexr.org/linux_mail_server.php|Creating a Linux Mail Server (Postfix, Procmail, Fetchmail, SpamBayes, Courier-imap, Mutt, SquirrelMail)]] * [[http://flurdy.com/docs/postfix/index.html|How to set up a mail server on a GNU / Linux system (Courier IMAP + Postfix)]] * [[http://www.howtoforge.com/postfix_amavisd_antispam|How To Combat Viruses Using Your Postfix Configuration]] * [[http://www.howtoforge.com/postfix_dkfilter_domain_keys_implementation|Postfix with dkfilter (DomainKeys Implementation)]] * [[http://osnews.com/story.php/17360/How-to-Implement-SPF-in-Postfix/|How-to Implement SPF in Postfix]] * [[http://www.howtoforge.de/howto/postfix-bounce-messages/|Postfix Bounce Messages anpassen]] * [[https://aws.amazon.com/articles/2405502737055650?ref_=pe_8050_20231810|Using Amazon SES in Python with Postman and Postfix]] ==== Logging ==== * [[http://www.seaglass.com/postfix/faq.html#lginc|Postfix FAQ: debug or verbose logging]] * [[http://www.seaglass.com/postfix/faq.html#lgsbj|Postfix FAQ: subject of a message on logs]] * [[http://www.howtoforge.de/howto/postfix-uberwachung-mit-mailgraph-und-pflogsumm/|Postfix Überwachung mit Mailgraph und pflogsumm]] ===== Verwaltung ===== ==== Bestandteile und Tools ==== FIXME ^ Bestandteil ^ Aufgabe ^ oft benutzte Aufrufe ^ | postalias | erzeugt die Alias-Datenbank | | | postconf | zeigt oder verändert die Postfix-Konfiguration | | | postfix-add-policy | | | | postmap | für Lookup-Tables | neue hash/btree-DB einer Klartextdatei erzeugen: postmap DATEI | | **postcat** | liest mails aus der mailqueue | Mail ausgeben: ''postcat -q ID'' | | postdrop | | | | postfix-add-filter | | | | postkick | | | | postlog | Möglichkeit für Scripts Lognachrichten zu erzeugen | | | **postqueue** | Verwaltet die Mail-Queue | Mails in Queue anzeigen: ''postqueue -p'' (//flush// mit ''-f'') | | **postsuper** | Manipulation an der Mail-Queue | einzelne Mail aus der queue löschen: ''postsuper -d ID'' oder alle ''postsuper -d ALL'' | ==== mails eines bestimmten Absenders auf hold setzen ==== für user@domain.tld: while true; do for i in $(mailq | grep user@domain.tld | grep -v \! | grep ^[a-zA-Z0-9] | awk {'print $1'} |sed s/*//g);do postsuper -h $i; done ; done und löschen: find /var/spool/postfix/hold/ -print0 | xargs -0 -r -P10 -n10 fgrep -l 'user@domain.tld' | xargs -P10 -r -n1 basename | xargs -P10 -r -n1 postsuper -d ==== rate-Limiting ==== * Versandprozesse limitieren (Beispiel: Auf 2 Prozess) * in der ''/etc/postfix/master.cf'': # service type private unpriv chroot wakeup maxproc command + args smtp unix - - - - 2 smtp * concurrency limitspostconf | grep '^\(default\|smtp\|relay\)[^ ]*concurrency[^ ]*'default_destination_concurrency_failed_cohort_limit = 1 default_destination_concurrency_limit = 20 default_destination_concurrency_negative_feedback = 1 default_destination_concurrency_positive_feedback = 1 relay_destination_concurrency_failed_cohort_limit = $default_destination_concurrency_failed_cohort_limit relay_destination_concurrency_limit = $default_destination_concurrency_limit relay_destination_concurrency_negative_feedback = $default_destination_concurrency_negative_feedback relay_destination_concurrency_positive_feedback = $default_destination_concurrency_positive_feedback relay_initial_destination_concurrency = $initial_destination_concurrency smtp_destination_concurrency_failed_cohort_limit = $default_destination_concurrency_failed_cohort_limit smtp_destination_concurrency_limit = $default_destination_concurrency_limit smtp_destination_concurrency_negative_feedback = $default_destination_concurrency_negative_feedback smtp_destination_concurrency_positive_feedback = $default_destination_concurrency_positive_feedback smtp_initial_destination_concurrency = $initial_destination_concurrency Für ein relay was nur in microsoft365 weiterleitet sollte das sehr gering ausfallen (siehe https://docs.microsoft.com/en-us/exchange/troubleshoot/send-emails/smtp-submission-improvements#new-throttling-limit-for-concurrent-connections-that-submitmessages ): # microsoft365 does not like more than 3 concurrent conns: default_destination_concurrency_limit=3 ==== Links ==== * [[http://sourceforge.net/projects/postfixadmin/|Postfix Admin]] * [[http://trac.brachium-system.net/cpves/|CpVES: Courier postfix Virtual Email System]] * [[http://sourceforge.net/projects/pocomy/|PoCoMy: Postfix + Courier + Mysql :: Webfrontend for administration]] ===== Fehlerbehebung ===== * nach postmap kommt dieser Fehler (''Postfix Error “fatal: open database /etc/postfix/transport.db: Invalid argument”'') Mails werden nicht mehr angenommen. Lösung: In der Konfiguration wird btree als Datenbankformat angegeben, postmap erstellt aber standardmäpßig hash-Datenbanken. Diser Eintrag in der ''/etc/postfix/main.cf'' behebt dies: default_database_type = btree * postfix start schlägt fehl: "Starting Postfix Mail Transport Agent: postfixfailure copying certificates ... failed!"aus $Gründen kommt Postfix nicht mehr mit diesen Angaben klar (nun auskommentiert) # smtpd_tls_CApath = /etc/ssl/certs # smtp_tls_CApath = /etc/ssl/certs ==== SSL/TLS debugging ==== ''/etc/postfix/main.cf'' smtpd_tls_received_header = yes smtpd_tls_loglevel = 3 # 0 (none) to 4 (full data) ==== /etc/sasldb2 No such file or directory ==== warning: SASL authentication problem: unable to open Berkeley db /etc/sasldb2: No such file or directory warning: unknown[x.x.x.x]: SASL LOGIN authentication failed: authentication failure Eine leere Datei legt dieser Befehl an: saslpasswd2 sasldb2 ===== Konfiguration ===== ==== Authentifizierung am Postfix-Relay (mit ClientCerts) ==== Wir brauchen als Vorraussetzung eine CA, diese stellt dann ein Zertifikat für den Client-MTA aus (''MY-CERT.key'' und ''MY-CERT.key'') aus. Man kopiert die beiden Zertifikatsdateien und dazu das Zertifikat (''CA.crt'') auf das Relay. = TLS Auth start = # ask clients for certs: smtpd_tls_ask_ccert=yes permit_tls_all_clientcerts = yes # SSL-Debug: # smtpd_tls_loglevel = 1 # Fingerprints of SSL-Certs i trust and relay for (i am the relay for these hosts and they auth via their ssl-Cert) relay_clientcerts = btree:/etc/postfix/relay_clientcerts # TLS parameters (certs/keys in pem-format) smtpd_tls_cert_file= /etc/postfix/MY-CERT.crt smtpd_tls_key_file= /etc/postfix/MY-CERT.key smtpd_tls_CAfile= /etc/postfix/CA.crt # enable STARTTLS outgoing: smtp_tls_security_level=may # enable STARTTLS incoming: smtpd_tls_security_level=may = TLS Auth end = Außerdem wird eine weitere Zeile zu den "''smtpd_recipient_restrictions''" hinzugefügt: smtpd_recipient_restrictions = ... permit_tls_clientcerts, ... Die Datei ''/etc/postfix/relay_clientcerts'' enthält den Fingerabdruck der Clients die sich am Relay damit authentifizieren wollen. # List all client-certs that are allowed to srelay mail over me # only MD5-Fingerprints (not SHA-1) seems to work, the comment is unimportant. # you get the fingerprint with: "openssl x509 -md5 -noout -fingerprint -in FILENAME-OF-CRT" # EA:0E:CD:21:19:0A:DE:DC:66:49:89:7B:E4:DF:7E:A3 Client XY ==== minimal nötiger freier Datenträgerplatz ==== ...um E-Mail anzunehmen: minimaler Platz [[http://www.postfix.org/postconf.5.html|queue_minfree]] (in Byte) ==== ssmtp und submission aktivieren ==== Die meisten Clients benutzen Port 25 und aktivieren SSL/TLS wenn angeboten (über STARTTLS), manche alte Client brauchen aber den Port 465 (SSMTP = SMTP + SSL). Außerdem blockieren einige Provider Port 25 ausgehend (um Spam einzudämmen), in diesem Fall brauchen diese Kunden auf dem Server Port 587 (submission) aktiviert. Beides lässt sich über die beiden folgenden Zeilen in der ''/etc/postfix/master.cf'' aktivieren: # some providers block Port 25 outgoing, so Port 587 (submission) in advised submission inet n - - - - smtpd -o smtpd_tls_security_level=encrypt -o smtpd_sasl_auth_enable=yes -o smtpd_client_restrictions=permit_sasl_authenticated,reject -o milter_macro_daemon_name=ORIGINATING # SMTP+SSL (SSMTP) on Port 465 smtps inet n - - - - smtpd -o smtpd_tls_wrappermode=yes -o smtpd_sasl_auth_enable=yes -o smtpd_client_restrictions=permit_sasl_authenticated,reject -o milter_macro_daemon_name=ORIGINATING ==== Mailarchivierung per Postfix ==== Postfix kann für Domains oder einzelne Empfänger Kopien erzeugen, damit kann ein Mailarchiv erreicht werden. In ''/etc/postfix/main.cf''((statt btree geht auch hash)): sender_bcc_maps = btree:/etc/postfix/sender_bcc recipient_bcc_maps = btree:/etc/postfix/recipient_bcc Ganze Domains: @domain.tld archiv@example.com @domain.eu archiv@example.com Einzelne Benutzer: info@domain.com chef@example.com kotakt@domain.eu archiv@example.com