Hier werden die Unterschiede zwischen zwei Versionen gezeigt.
— |
postfix [2017/10/02 13:40] (aktuell) |
||
---|---|---|---|
Zeile 1: | Zeile 1: | ||
+ | ====== Allgemein ====== | ||
+ | Dieser Artikel beschreibt wie **Postfix** auf einem Mailserver installiert wird. Will man auf einem Desktoprechner [[Postfix als lokalen MTA einsetzen]] so sollte dem entsprechenden Artikel gefolgt werden, da es gewisse Unterschiede gibt. | ||
+ | |||
+ | ====== Voraussetzung ====== | ||
+ | Ein aktueller Port-Tree und **root**-Rechte sind Voraussetzung für die Installation von **postfix**. | ||
+ | Des weiteren sind für den Betrieb als Mailserver ein gültiger MX-Eintrag notwendig. | ||
+ | |||
+ | Will man einen sicheren Server haben muss zunächst noch ein [[OpenSSL Zertifikat erstellen]] und [[CyrusSASL]] installieren und konfigurieren. | ||
+ | |||
+ | ====== Installation ====== | ||
+ | <code> | ||
+ | # cd /usr/ports/mail/postfix | ||
+ | # make install clean | ||
+ | </code> | ||
+ | |||
+ | ===== Optionen ===== | ||
+ | Als Optionen werden folgende Punkte angewählt: | ||
+ | <code> | ||
+ | [X] PCRE Perl Compatible Regular Expressions | ||
+ | [X] SASL2 Cyrus SASLv2 (Simple Auth. and Sec. Layer) | ||
+ | [ ] DOVECOT Dovecot SASL authentication method | ||
+ | [ ] SASLKRB If your SASL req. Kerberos select this option | ||
+ | [ ] SASLKRB5 If your SASL req. Kerberos5 select this option | ||
+ | [ ] SASLKMIT If your SASL req. MIT Kerberos5 select this option | ||
+ | [X] TLS Enable SSL and TLS support | ||
+ | [ ] BDB Berkeley DB (choose version with WITH_BDB_VER) | ||
+ | [ ] MYSQL MySQL maps (choose version with WITH_MYSQL_VER) | ||
+ | [ ] PGSQL PostgreSQL maps (choose with DEFAULT_PGSQL_VER) | ||
+ | [ ] OPENLDAP OpenLDAP maps (choose ver. with WITH_OPENLDAP_VER) | ||
+ | [ ] CDB CDB maps lookups | ||
+ | [ ] NIS NIS maps lookups | ||
+ | [ ] VDA VDA (Virtual Delivery Agent 32Bit) | ||
+ | [ ] TEST SMTP/LMTP test server and generator | ||
+ | </code> | ||
+ | Auf die Frage | ||
+ | <code> | ||
+ | You need user "postfix" added to group "mail". | ||
+ | Would you like me to add it [y]? | ||
+ | </code> | ||
+ | wird mit **y** geantwortet | ||
+ | und | ||
+ | <code> | ||
+ | Would you like to activate Postfix in /etc/mail/mailer.conf [n]? | ||
+ | </code> | ||
+ | wird auch mit **y** bestätigt. | ||
+ | |||
+ | ====== Postfix konfigurieren ====== | ||
+ | Die Datei **/usr/local/etc/postfix/main.cf** enthält die Konfiguration von **postfix**. | ||
+ | Die folgenden Zeilen werden aktiviert (das führende **#** entfernt): | ||
+ | <code> | ||
+ | myhostname = EIGENER-HOSTNAME | ||
+ | myorigin = $myhostname | ||
+ | mydestination = $myhostname, localhost.$mydomain, localhost, $mydomain | ||
+ | mynetworks_style = host | ||
+ | home_mailbox = Maildir/ | ||
+ | </code> | ||
+ | |||
+ | In die Zeile //mydestination// können auch noch mehr Domainnamen eingetragen werden für welche der Server Mails akzeptieren soll. | ||
+ | |||
+ | |||
+ | Zur Aktivierung von CyrusSASL und OpenSSL werden folgende Zeilen hinzugefügt: | ||
+ | <code> | ||
+ | smtp_sasl_auth_enable = yes | ||
+ | smtpd_sasl_auth_enable = yes | ||
+ | smtpd_sasl_security_options = noanonymous | ||
+ | smtpd_sasl_local_domain = $mydomain | ||
+ | broken_sasl_auth_clients = yes | ||
+ | smtp_sasl_password_maps = hash:/usr/local/etc/sasldb2 | ||
+ | smtpd_recipient_restrictions = permit_sasl_authenticated permit_mynetworks reject_unauth_destination | ||
+ | |||
+ | smtp_tls_CAfile = /etc/opensslcerts/official-mail.crt | ||
+ | smtp_tls_cert_file = /etc/opensslcerts/official-mail.crt | ||
+ | smtp_tls_key_file = /etc/opensslcerts/mail.key | ||
+ | smtp_tls_session_cache_database = btree:/var/run/smtp_tls_session_cache | ||
+ | smtp_tls_security_level = may | ||
+ | smtpd_tls_CAfile = /etc/opensslcerts/official-mail.crt | ||
+ | smtpd_tls_cert_file = /etc/opensslcerts/official-mail.crt | ||
+ | smtpd_tls_key_file = /etc/opensslcerts/mail.key | ||
+ | smtpd_tls_session_cache_database = btree:/var/run/smtpd_tls_session_cache | ||
+ | smtpd_tls_received_header = yes | ||
+ | smtpd_tls_security_level = may | ||
+ | tls_random_source = dev:/dev/urandom | ||
+ | smtpd_tls_auth_only = yes | ||
+ | </code> | ||
+ | |||
+ | Als nächstes wird die Alias-Datenbank neu angelegt und an die für **postfix** richtige Stelle verlinkt. | ||
+ | <code> | ||
+ | # postalias /etc/mail/aliases | ||
+ | # ln -s /etc/mail/aliases.db /etc/aliases.db | ||
+ | # newaliases | ||
+ | </code> | ||
+ | |||
+ | ====== Postfix starten ====== | ||
+ | Damit **postfix** beim nächsten Start geladen wird und **sendmail** nicht weiter für den Mailverkehr genutzt wird muss die **/etc/rc.conf** um folgende Zeilen erweitert werden: | ||
+ | <code> | ||
+ | # Postfix statt Sendmail | ||
+ | postfix_enable="YES" | ||
+ | sendmail_enable="NO" | ||
+ | sendmail_submit_enable="NO" | ||
+ | sendmail_outbound_enable="NO" | ||
+ | sendmail_msp_queue_enable="NO" | ||
+ | </code> | ||
+ | |||
+ | ====== Sendmail Wartung deaktivieren ====== | ||
+ | Anschliessend wird die Datei /etc/periodic.conf erzeugt und folgende Zeilen in selbige eingefügt um keine Wartungsarbeiten mehr an **sendmail** vorzunehmen. | ||
+ | <code> | ||
+ | daily_clean_hoststat_enable="NO" | ||
+ | daily_status_mail_rejects_enable="NO" | ||
+ | daily_status_include_submit_mailq="NO" | ||
+ | daily_submit_queuerun="NO" | ||
+ | </code> | ||