postfix
Unterschiede
Hier werden die Unterschiede zwischen zwei Versionen angezeigt.
| Beide Seiten der vorigen RevisionVorhergehende Überarbeitung | |||
| postfix [2025-05-26 00:41:44] – david | postfix [2025-05-26 00:48:29] (aktuell) – david | ||
|---|---|---|---|
| Zeile 1: | Zeile 1: | ||
| + | ====== Postfix ====== | ||
| + | |||
| + | * [[https:// | ||
| + | * [[https:// | ||
| + | |||
| + | |||
| + | ==== Erstinstallation ==== | ||
| + | |||
| + | siehe auch: [[:: | ||
| + | |||
| + | - VM-Installation | ||
| + | - Nacharbeiten (in der neuen Umgebung): | ||
| + | - '' | ||
| + | - '' | ||
| + | - '' | ||
| + | - '' | ||
| + | - '' | ||
| + | - -> [[http:// | ||
| + | - '' | ||
| + | - '' | ||
| + | |||
| + | Rekonfiguration: | ||
| + | > dpkg-reconfigure postfix | ||
| + | |||
| + | |||
| + | ===== Postfix-Grundwissen ===== | ||
| + | |||
| + | |||
| + | Postfix wird Nachrichten, | ||
| + | mydestination | ||
| + | |||
| + | wenn lokale Mails nur mit dem User-Namen versendet werden (z.B. " | ||
| + | myorigin | ||
| + | |||
| + | Liste der Domains, zu denen weiter geleitet werden darf: | ||
| + | relay_domains | ||
| + | |||
| + | hier steht, wohin entsprechende Domains, SubDomains oder E-Mail-Adressen weitergeleitet werden: | ||
| + | relay_transport | ||
| + | |||
| + | hier steht, wohin entsprechende E-Mails weitergeleitet werden: | ||
| + | virtual_alias_maps | ||
| + | |||
| + | hier werden ihm die Domainersetzungen mitgeteilt, es bewirkt das gleiche wie „virtual“ nur das hierbei in der Mail auch noch die Zieladresse ausgetauscht wird: | ||
| + | smtp_generic_maps | ||
| + | |||
| + | hiermit werden Absende- und Empfänger-Adresse ausgetauscht, | ||
| + | canonical_maps | ||
| + | |||
| + | |||
| + | ===== wissenswertes ===== | ||
| + | |||
| + | * [[http:// | ||
| + | |||
| + | Mail-Queue ansehen: | ||
| + | > mailq | ||
| + | |||
| + | komplette Mail-Queue leeren: | ||
| + | > postsuper -d ALL | ||
| + | |||
| + | |||
| + | * [[https:// | ||
| + | |||
| + | vi / | ||
| + | ... | ||
| + | ### Specifies whether or not mail that would normally be bounced | ||
| + | ### should be queued for redelivery attempts. Also converts any | ||
| + | ### permanent rejection codes to temporary error codes. This parameter | ||
| + | ### is useful for testing out configuration changes | ||
| + | ### to make sure that no mail is permanently rejected. | ||
| + | soft_bounce = yes | ||
| + | ... | ||
| + | ### alle unzustellbaren Mails in Fritz seinem lokalen Postfach ablegen | ||
| + | luser_relay = fritz | ||
| + | ... | ||
| + | |||
| + | Wenn man keine Transport-Tabelle eingerichtet hat ('' | ||
| + | Bei dem Verbindungsaufbau meldet der Postfix sich beim '' | ||
| + | |||
| + | ===== Absendeadresse ===== | ||
| + | |||
| + | * [[http:// | ||
| + | * [[http:// | ||
| + | * [[http:// | ||
| + | * [[http:// | ||
| + | * [[http:// | ||
| + | |||
| + | Die ''// | ||
| + | |||
| + | Den // | ||
| + | # sudo dpkg-reconfigure postfix | ||
| + | |||
| + | oder so: | ||
| + | # echo " | ||
| + | # sed -i -e ' | ||
| + | # echo " | ||
| + | |||
| + | verwendet man ein SSL-Zertifikat, | ||
| + | # hostname -f > / | ||
| + | # sed -i -e ' | ||
| + | # echo " | ||
| + | |||
| + | Dann den Restart des Dienstes nicht vergessen: | ||
| + | # / | ||
| + | |||
| + | |||
| + | ===== Exitcodes ===== | ||
| + | |||
| + | Wenn Postfix eine Mail per Pipe an ein externes Script weitergeben möchte, | ||
| + | es aber aber zu Zwischenfällen kommt, hat das Return-Mails zur Folge, | ||
| + | die folgende Exitcodes enthalten können: | ||
| + | |||
| + | ^Status ^ $? ^ Description ^ | ||
| + | | EX_OK | | ||
| + | | EX_USAGE | 64 | command line usage error | | ||
| + | | EX_DATAERR | 65 | data format error | | ||
| + | | EX_NOINPUT | 66 | cannot open input | | ||
| + | | EX_NOUSER | 67 | addressee unknown | | ||
| + | | EX_NOHOST | 68 | host name unknown | | ||
| + | | EX_UNAVAILABLE | 69 | service unavailable | | ||
| + | | EX_SOFTWARE | 70 | internal software error | | ||
| + | | EX_OSERR | 71 | system error (e.g., can't fork) | | ||
| + | | EX_OSFILE | 72 | critical OS file missing | | ||
| + | | EX_CANTCREAT | 73 | can't create (user) output file | | ||
| + | | EX_IOERR | 74 | input/ | ||
| + | | EX_TEMPFAIL | 75 | temp failure; user is invited to retry | | ||
| + | | EX_PROTOCOL | 76 | remote error in protocol | | ||
| + | | EX_NOPERM | 77 | permission denied | | ||
| + | | EX_CONFIG | 78 | configuration error | | ||
| + | |||
| + | |||
| + | ===== Installation ===== | ||
| + | |||
| + | |||
| + | ==== ohne virtuelle Mail-Boxen ==== | ||
| + | |||
| + | Am einfachsten kann man den Mailserver mit Binär-Paketen installieren: | ||
| + | # pkg install postfix-tls-2.11.1_2, | ||
| + | |||
| + | für die Mail-Verwaltung von System-Benutzern, | ||
| + | |||
| + | verschlüsseltes Mails lesen ist möglich (z.B. IMAP -> Port 143 mit STARTTLS oder Port 993 mit SSL) aber eMails kann man nur unverschlüsselt senden (Port 25) | ||
| + | postfix/ | ||
| + | |||
| + | |||
| + | ==== mit virtuelle Mail-Boxen ==== | ||
| + | |||
| + | Für die Verwaltung von virtuellen Mail-Boxen brauchen wir SASL-Unterstützung, | ||
| + | leider sind die Binär-Pakete aber ohne SASL-Unterstützung kompiliert worden, | ||
| + | deshalb müssen wir die Programme zu Fuß installieren: | ||
| + | # pkg search portupgrade | ||
| + | portupgrade-2.4.12_2, | ||
| + | # pkg install portupgrade-2.4.12_2, | ||
| + | # portupgrade -NRO mail/ | ||
| + | |||
| + | Da ich Sieve-Unterstützung in Dovecot brauche und zur Zeit nur Dovecot in der Version 1 | ||
| + | Sieve unterstützt, | ||
| + | Und SSL-Unterstützung brauche ich selbstverständlich auch: | ||
| + | [*] PCRE Perl Compatible Regular Expressions | ||
| + | [*] SASL2 Cyrus SASLv2 (Simple Auth. and Sec. Layer) | ||
| + | [*] DOVECOT | ||
| + | ... | ||
| + | [*] TLS Enable SSL and TLS support | ||
| + | ... | ||
| + | |||
| + | **'' | ||
| + | |||
| + | Warning: you still need to edit myorigin/ | ||
| + | parameter settings in / | ||
| + | | ||
| + | See also http:// | ||
| + | for information about dialup sites or about sites inside a | ||
| + | firewalled network. | ||
| + | | ||
| + | BTW: Check your / | ||
| + | that send mail for root and postmaster to a real person, then | ||
| + | run / | ||
| + | | ||
| + | install | ||
| + | install | ||
| + | install | ||
| + | ===> Installing rc.d startup script(s) | ||
| + | Would you like to activate Postfix in / | ||
| + | |||
| + | To enable postfix startup script please add postfix_enable=" | ||
| + | your rc.conf | ||
| + | | ||
| + | If you not need sendmail anymore, please add in your rc.conf: | ||
| + | | ||
| + | sendmail_enable=" | ||
| + | sendmail_submit_enable=" | ||
| + | sendmail_outbound_enable=" | ||
| + | sendmail_msp_queue_enable=" | ||
| + | | ||
| + | And you can disable some sendmail specific daily maintenance routines in your | ||
| + | / | ||
| + | | ||
| + | daily_clean_hoststat_enable=" | ||
| + | daily_status_mail_rejects_enable=" | ||
| + | daily_status_include_submit_mailq=" | ||
| + | daily_submit_queuerun=" | ||
| + | | ||
| + | If / | ||
| + | | ||
| + | If you are using SASL, you need to make sure that postfix has access to read | ||
| + | the sasldb file. This is accomplished by adding postfix to group mail and | ||
| + | making the / | ||
| + | be the default for new installs). | ||
| + | | ||
| + | If you are upgrading from Postfix 2.6 or earlier, review the RELEASE_NOTES to | ||
| + | familiarize yourself with new features and incompatabilities. | ||
| + | |||
| + | This port has installed the following startup scripts which may cause | ||
| + | these network services to be started at boot time. | ||
| + | / | ||
| + | | ||
| + | If there are vulnerabilities in these programs there may be a security | ||
| + | risk to the system. FreeBSD makes no guarantee about the security of | ||
| + | ports included in the Ports Collection. Please type 'make deinstall' | ||
| + | to deinstall the port if this is a concern. | ||
| + | | ||
| + | For more information, | ||
| + | status of this software, see the following webpage: | ||
| + | http:// | ||
| + | ===> | ||
| + | |||
| + | # ldd / | ||
| + | libsasl2.so.2 => / | ||
| + | ... | ||
| + | |||
| + | # postconf -A | ||
| + | cyrus | ||
| + | |||
| + | # postconf -a | ||
| + | dovecot | ||
| + | |||
| + | |||
| + | ==== LDA Postfix ==== | ||
| + | |||
| + | **Diese Informationen finden Sie in der aktuellen Version in FreeBSD unter /// | ||
| + | |||
| + | === System users === | ||
| + | |||
| + | You can use deliver with a few selected system users (ie. user is found from | ||
| + | '/ | ||
| + | |||
| + | | "/ | ||
| + | |||
| + | This should work with any MTA which supports per-user ' | ||
| + | (For qmail' | ||
| + | |||
| + | This method doesn' | ||
| + | it's executed as the user itself. | ||
| + | |||
| + | ---- | ||
| + | |||
| + | If you wish you use ' | ||
| + | you can do it by editing ' | ||
| + | |||
| + | "/ | ||
| + | |||
| + | mailbox_command = / | ||
| + | |||
| + | Then run ' | ||
| + | |||
| + | |||
| + | === Virtual users === | ||
| + | |||
| + | Dovecot LDA is very easy to use on large scale installations with Postfix | ||
| + | virtual domains support, just add a ' | ||
| + | "/ | ||
| + | |||
| + | dovecot | ||
| + | flags=DRhu user=vmail: | ||
| + | |||
| + | An example using address extensions (ie user+extension@domain.com) to deliver | ||
| + | to the folder ' | ||
| + | ${extension}, | ||
| + | sure to utilize< | ||
| + | locations and other configuration parameters that are expecting lower case): | ||
| + | |||
| + | dovecot unix - | ||
| + | flags=DRhu user=vmail: | ||
| + | |||
| + | # or with v1.1.2+ if you have a INBOX/ namespace prefix: | ||
| + | dovecot unix - | ||
| + | flags=DRhu user=vmail: | ||
| + | |||
| + | This example ignores address extensions (ie user+extension@domain.com delivers | ||
| + | just like user@domain.com): | ||
| + | |||
| + | dovecot | ||
| + | flags=DRhu user=vmail: | ||
| + | |||
| + | dovecot | ||
| + | flags=DRhu user=vmail: | ||
| + | |||
| + | Replace ' | ||
| + | |||
| + | Then set ' | ||
| + | |||
| + | dovecot_destination_recipient_limit = 1 | ||
| + | virtual_mailbox_domains = your.domain.here | ||
| + | virtual_transport = dovecot | ||
| + | |||
| + | And remember to run | ||
| + | |||
| + | postfix reload | ||
| + | |||
| + | |||
| + | === authentication socket === | ||
| + | |||
| + | > vi / | ||
| + | ... | ||
| + | protocol lda { | ||
| + | ... | ||
| + | # UNIX socket path to master authentication server to find users. | ||
| + | # | ||
| + | } | ||
| + | auth default { | ||
| + | ... | ||
| + | socket listen { | ||
| + | master { | ||
| + | # Master socket provides access to userdb information. It's typically | ||
| + | # used to give Dovecot' | ||
| + | # can find mailbox locations. | ||
| + | path = / | ||
| + | mode = 0600 | ||
| + | # Default user/group is the one who started dovecot-auth (root) | ||
| + | #user = | ||
| + | #group = | ||
| + | group = mail | ||
| + | } | ||
| + | client { | ||
| + | # The client socket is generally safe to export to everyone. Typical use | ||
| + | # is to export it to your SMTP server so it can do SMTP AUTH lookups | ||
| + | # using it. | ||
| + | path = / | ||
| + | mode = 0660 | ||
| + | user = postfix | ||
| + | group = mail | ||
| + | } | ||
| + | } | ||
| + | } | ||
| + | |||
| + | ---- | ||
| + | |||
| + | ==== weitere Links ==== | ||
| + | |||
| + | http:// | ||
| + | |||
| + | ==== Beispiel aus Ubuntu 09.10 ==== | ||
| + | |||
| + | postconf -n | ||
| + | |||
| + | alias_database = hash:/ | ||
| + | alias_maps = hash:/ | ||
| + | append_dot_mydomain = no | ||
| + | biff = no | ||
| + | broken_sasl_auth_clients = yes | ||
| + | config_directory = / | ||
| + | home_mailbox = Maildir/ | ||
| + | inet_interfaces = all | ||
| + | mailbox_command = / | ||
| + | mailbox_size_limit = 0 | ||
| + | mydestination = hostname, localhost.localdomain, | ||
| + | myhostname = hostname | ||
| + | mynetworks = 127.0.0.0/8 [:: | ||
| + | readme_directory = no | ||
| + | recipient_delimiter = + | ||
| + | relayhost = | ||
| + | smtp_tls_session_cache_database = btree: | ||
| + | smtp_use_tls = yes | ||
| + | smtpd_banner = $myhostname ESMTP $mail_name (Ubuntu) | ||
| + | smtpd_recipient_restrictions = reject_unknown_sender_domain, | ||
| + | smtpd_sasl_auth_enable = yes | ||
| + | smtpd_sasl_authenticated_header = yes | ||
| + | smtpd_sasl_local_domain = $myhostname | ||
| + | smtpd_sasl_path = private/ | ||
| + | smtpd_sasl_security_options = noanonymous | ||
| + | smtpd_sasl_type = dovecot | ||
| + | smtpd_sender_restrictions = reject_unknown_sender_domain | ||
| + | smtpd_tls_auth_only = yes | ||
| + | smtpd_tls_cert_file = / | ||
| + | smtpd_tls_key_file = / | ||
| + | smtpd_tls_mandatory_ciphers = medium | ||
| + | smtpd_tls_mandatory_protocols = TLSv1.1, TLSv1.2, TLSv1, !SSLv3, !SSLv2 | ||
| + | smtpd_tls_received_header = yes | ||
| + | smtpd_tls_session_cache_database = btree: | ||
| + | smtpd_use_tls = yes | ||
| + | tls_random_source = dev:/ | ||
| + | |||
| + | |||
| + | ==== Beispiel aus Ubuntu 12.04 LTS ==== | ||
| + | |||
| + | Meistens ist [[http:// | ||
| + | |||
| + | |||
| + | === SMTP-STARTTLS-Verschlüsselung aktivieren ===== | ||
| + | |||
| + | SSL-Schlüssel generieren: | ||
| + | < | ||
| + | #!/bin/bash | ||
| + | |||
| + | RECHNERNAME=" | ||
| + | |||
| + | EMAIL=" | ||
| + | STAAT=" | ||
| + | LAND=" | ||
| + | STADT=" | ||
| + | ORGANISATION=" | ||
| + | ABTEILUNG=" | ||
| + | ZEITRAUM=" | ||
| + | BITLANG=" | ||
| + | |||
| + | |||
| + | openssl req -rand / | ||
| + | |||
| + | |||
| + | if [ -r "/ | ||
| + | echo "/ | ||
| + | fi | ||
| + | |||
| + | if [ -r "/ | ||
| + | echo "/ | ||
| + | openssl x509 -noout -subject -issuer -dates -in / | ||
| + | fi | ||
| + | </ | ||
| + | |||
| + | |||
| + | === / | ||
| + | |||
| + | * [[http:// | ||
| + | |||
| + | Hier müssen folgende Variablen angepasst werden: | ||
| + | - **home_mailbox** | ||
| + | - **mydestination** | ||
| + | - **mynetworks** | ||
| + | - **smtpd_tls_cert_file** | ||
| + | - **smtpd_tls_key_file** | ||
| + | |||
| + | sowie die beiden Variablen um nichtzustellbaren Mails zwischenzuspeichern, | ||
| + | - **smtp_connection_cache_on_demand** | ||
| + | - **smtp_connection_cache_destinations** | ||
| + | |||
| + | # See / | ||
| + | | ||
| + | | ||
| + | # Debian specific: | ||
| + | # line of that file to be used as the name. The Debian default | ||
| + | # is / | ||
| + | #myorigin = / | ||
| + | | ||
| + | smtpd_banner = $myhostname ESMTP $mail_name (Ubuntu) | ||
| + | biff = no | ||
| + | | ||
| + | # appending .domain is the MUA's job. | ||
| + | append_dot_mydomain = no | ||
| + | | ||
| + | # Uncomment the next line to generate " | ||
| + | # | ||
| + | | ||
| + | readme_directory = no | ||
| + | | ||
| + | # TLS parameters | ||
| + | # | ||
| + | # | ||
| + | smtpd_tls_cert_file = / | ||
| + | smtpd_tls_key_file = / | ||
| + | smtpd_use_tls = yes | ||
| + | smtpd_tls_session_cache_database = btree: | ||
| + | smtp_tls_session_cache_database = btree: | ||
| + | | ||
| + | # See / | ||
| + | # information on enabling SSL in the smtp client. | ||
| + | | ||
| + | myhostname = postbote.domain.de | ||
| + | alias_maps = hash:/ | ||
| + | alias_database = hash:/ | ||
| + | myorigin = / | ||
| + | mydestination = postbote.domain.de, | ||
| + | relayhost = smtp.domain.de | ||
| + | mynetworks = 127.0.0.0/8 [:: | ||
| + | mailbox_size_limit = 0 | ||
| + | recipient_delimiter = + | ||
| + | inet_interfaces = all | ||
| + | home_mailbox = Maildir/ | ||
| + | smtpd_sasl_auth_enable = yes | ||
| + | smtpd_sasl_type = dovecot | ||
| + | smtpd_sasl_path = private/ | ||
| + | smtpd_sasl_authenticated_header = yes | ||
| + | smtpd_sasl_security_options = noanonymous | ||
| + | smtpd_sasl_local_domain = $myhostname | ||
| + | broken_sasl_auth_clients = yes | ||
| + | smtpd_recipient_restrictions = reject_unknown_sender_domain, | ||
| + | smtpd_sender_restrictions = reject_unknown_sender_domain | ||
| + | mailbox_command = / | ||
| + | smtp_use_tls = yes | ||
| + | smtpd_tls_received_header = yes | ||
| + | smtpd_tls_mandatory_protocols = TLSv1.1, TLSv1.2, TLSv1, !SSLv3, !SSLv2 | ||
| + | smtpd_tls_mandatory_ciphers = medium | ||
| + | smtpd_tls_auth_only = yes | ||
| + | tls_random_source = dev:/ | ||
| + | smtp_connection_cache_on_demand = yes | ||
| + | smtp_connection_cache_destinations = $relayhost | ||
| + | |||
| + | |||
| + | == Postfix für mehr als eine Domain konfigurieren == | ||
| + | |||
| + | * [[http:// | ||
| + | |||
| + | Postfix nimmt nur Mails an, die in dieses Muster passen bzw. zu diesen Domains gehören. Das bedeutet, wenn man eine eMail verschicken will, muss die Domain, die hinter dem " | ||
| + | relay_domains = $mydestination domain.de domain.net domain.org | ||
| + | |||
| + | ...oder in dieser Datei stehen: | ||
| + | vi / | ||
| + | gmx.net | ||
| + | gmx.de | ||
| + | web.de | ||
| + | | ||
| + | postmap / | ||
| + | | ||
| + | vi / | ||
| + | ... | ||
| + | relay_domains = $mydestination, | ||
| + | ... | ||
| + | |||
| + | hier werden ihm die Weiterleitungsziele (quelle@domain.de -> ziel@mein.postfach) mitgeteilt: | ||
| + | virtual_alias_maps = hash:/ | ||
| + | < | ||
| + | # | ||
| + | # postmap / | ||
| + | # | ||
| + | @domain.de | ||
| + | @domain.net | ||
| + | @domain.org | ||
| + | rechnungen@domain.de | ||
| + | news@domain.de | ||
| + | freunde@domain.de | ||
| + | </ | ||
| + | |||
| + | hier werden ihm die Domainersetzungen mitgeteilt, es bewirkt das gleiche wie " | ||
| + | smtp_generic_maps = hash:/ | ||
| + | < | ||
| + | # | ||
| + | # postmap / | ||
| + | # | ||
| + | @internetshop.de | ||
| + | @forum.net | ||
| + | @facebook.org | ||
| + | </ | ||
| + | |||
| + | hiermit werden Absende- und Empfänger-Adresse ausgetauscht, | ||
| + | canonical_maps = hash:/ | ||
| + | |||
| + | |||
| + | === / | ||
| + | |||
| + | Um auch den Port 465 zu öffnen, müssen hier die Zeile mit **SMTPS** am Anfang | ||
| + | und die dazugehörigen Zeilen darunter aktiviert werden. | ||
| + | |||
| + | ... | ||
| + | smtps | ||
| + | -o syslog_name=postfix/ | ||
| + | -o smtpd_tls_wrappermode=yes | ||
| + | -o smtpd_sasl_auth_enable=yes | ||
| + | -o smtpd_client_restrictions=permit_sasl_authenticated, | ||
| + | -o milter_macro_daemon_name=ORIGINATING | ||
| + | ... | ||
| + | |||
| + | |||
| + | === SMTP-STARTTLS-Verschlüsselung testen ===== | ||
| + | |||
| + | * [[http:// | ||
| + | |||
| + | > telnet mail.domain.de 25 | ||
| + | Trying 192.186.1.142... | ||
| + | Connected to mail.domain.de. | ||
| + | Escape character is ' | ||
| + | 220 mail.domain.de ESMTP Postfix (Ubuntu) | ||
| + | EHLO mail.domain.de | ||
| + | 250-mail.domain.de | ||
| + | 250-PIPELINING | ||
| + | 250-SIZE 10240000 | ||
| + | 250-VRFY | ||
| + | 250-ETRN | ||
| + | 250-STARTTLS | ||
| + | 250-ENHANCEDSTATUSCODES | ||
| + | 250-8BITMIME | ||
| + | 250 DSN | ||
| + | STARTTLS | ||
| + | 220 2.0.0 Ready to start TLS | ||
| + | |||
| + | > openssl s_client -starttls smtp -connect mail.domain.de: | ||
| + | ... | ||
| + | --- | ||
| + | SSL handshake has read 2738 bytes and written 354 bytes | ||
| + | --- | ||
| + | New, TLSv1/ | ||
| + | Server public key is 4096 bit | ||
| + | Secure Renegotiation IS supported | ||
| + | Compression: | ||
| + | Expansion: NONE | ||
| + | SSL-Session: | ||
| + | Protocol | ||
| + | Cipher | ||
| + | Session-ID: 49862F23385CD9AC3D85F09AE17F25209B358E2A11DE580C3EF2761BE656D75B | ||
| + | Session-ID-ctx: | ||
| + | Master-Key: A6E58F2E1E3D0D365AB1E2E9AE3E9B4B8F46095FA1583242FCD7FD115B11F4DD6FB720E986A8DEC9208CA335B432C0C3 | ||
| + | Key-Arg | ||
| + | Start Time: 1381866777 | ||
| + | Timeout | ||
| + | Verify return code: 18 (self signed certificate) | ||
| + | --- | ||
| + | 250 DSN | ||
| + | DONE | ||
| + | |||
