PostfixSetup

Siehe auch: MailmanSetup

Grundlage:

Installation

apt-get install postfix --no-install-recommends

Dann auswählen:
  1. "Internet Site"
  2. Den Hostname, z.B. "web.irgitsch.de"
In der /etc/main.cf hinzufügen bzw. ändern / ergänzen:
  1. myhostname = <hostname des systems, z.B. web.irgitsch.de>
  2. mydestination = stadtlandfrucht.de, einexperte.de, ... [alle domains auf dem Server + Standardwerte, durch Komma getrennt]
  3. mynetworks = 127.0.0.0/8 [::ffff:127.0.0.0]/104 [IP-Adresses, z.B. 5.9.105.121/32 + Standardwerte, durch Leerzeichen getrennt]
  4. smtpd_recipient_restrictions = permit_mynetworks, reject_unauth_destination, reject_invalid_hostname, reject_unknown_recipient_domain
  5. smtpd_helo_restrictions = reject_invalid_helo_hostname, reject_non_fqdn_helo_hostname, reject_unknown_helo_hostname
  6. home_mailbox = Maildir/
  7. mailbox_command =
Postfix neu starten:
  • Mit SysVinit-Skripten
    /etc/init.d/postfix restart
  • Mit Systemd
    systemctl restart postfix

Virtuelle Postfächer / Benutzer

Um nicht für jedes Postfach einen Systembenutzer anlegen zu müssen ...

Hilfreich: https://wiki.archlinux.org/index.php/Virtual_user_mail_system_with_Postfix,_Dovecot_and_Roundcube

Benutzer vmail anlegen, Verzeichnis erstellen, Rechte vergeben
groupadd -g 5000 vmail
useradd -u 5000 -g vmail -s /usr/bin/nologin -d /var/mail/vhosts -m vmail
mkdir -p /var/mail/vhosts/einexperte.de/irgend
cd /var/mail/vhosts/einexperte.de/irgend
mkdir cur new tmp
chown -R vmail:vmail /var/mail/vhosts

Konfigurationsdatei main.cf anpassen:
root@mail:/etc/postfix# diff main.cf-2018-10-14 main.cf
49a50,56
> virtual_mailbox_domains = einexperte.de
> virtual_mailbox_base = /var/mail/vhosts
> virtual_mailbox_maps = hash:/etc/postfix/vmailbox
> virtual_minimum_uid = 100
> virtual_uid_maps = static:5000
> virtual_gid_maps = static:5000
> #virtual_alias_maps = hash:/etc/postfix/virtual

Datei mit Mailbox-Definitionen anlegen:
root@mail:/etc/postfix# cat vmailbox
irgend@einexperte.de    einexperte.de/irgend/

Postfix-Konfiguration neu laden

root@mail:/etc/postfix# postmap vmailbox 
root@mail:/etc/postfix# postfix reload
postfix/postfix-script: refreshing the Postfix mail system

DNS-Einstellungen

Dann im Nameserver die SPF-Einträge vornehmen, z.B.:
irgitsch.de txt 0 v=spf1 mx ip4:85.10.196.217 -all

Automatisches PGP für ausgehende Mails

Ein E-Mail Server kann für ausgehende Mail's eine automatische verschlüsselung vornehmen. Das ist vor allem gut wenn der Server automatisch Nachrichten versendet.

https://github.com/TheGreatGooo/gpg-mailgate

Anleitung unter INSTALL befolgen. Es muss nicht nobody verwendet werden. Es funktioniert auch mit einem eigenen Benutzer für den Dienst:
useradd -d /var/gpgmailgate -r gpgmailuser

Das entschlüsseln soll ebenso funktionieren, wurde aber nicht getestet.

SpamAssassin benutzen, um Spam E-Mails abzuweisen

Siehe: https://serverfault.com/questions/146855/how-to-make-spamassasin-reject-mail-based-on-score

Inhalt:

You can configure postfix to use Spamassasin/Amavis as a proxy-filter. This way you prevent bounces: The connection to the SMTP remote side will remain open until the spam checks are done and postfix will response either with a OK or REJECTED message. This way, the remote side is responsible for bounces.

# master.cf

# mail inbound
smtp      inet  n       -       -       -       -       smtpd
    -o smtpd_proxy_filter=127.0.0.1:10024
    -o smtpd_client_connection_count_limit=10
    -o smtpd_proxy_options=speed_adjust

# spamassasin/amavis is listening to port 10024 and sending it's
# checked mail to port 10025
amavis    unix  -       -       n       -       2       smtp
   -o smtp_data_done_timeout=1200
   -o smtp_send_xforward_command=yes
   -o disable_dns_lookups=yes

# SMTP return (from amavis/spamassasin)
localhost:10025 inet  n -       n       -      -        smtpd
   -o content_filter=
   -o local_recipient_maps=
   -o relay_recipient_maps=
   -o smtpd_restriction_classes=
   -o smtpd_client_restrictions=
   -o smtpd_helo_restrictions=
   -o smtpd_sender_restrictions=
   -o smtpd_recipient_restrictions=permit_mynetworks,reject
   -o smtpd_override_options=no_address_mappings
   -o mynetworks=127.0.0.0/8
   -o receive_override_options=no_unknown_recipient_checks

# main.cf

# for rejecting spam
header_checks = pcre:/etc/postfix/header_checks

# header_checks

/X-Spam-Level: \*{9,}/ REJECT Looks like spam to me.

If you are using Amavis to call spamassasin, you can let Amavis reject the mail for you - the reject threashold can be configured with $sa_kill_level_deflt. Add ,no_header_body_checks to the receive_override_options at the SMTP return entry when using Amavis.

Topic-Revision: r9 - 01 Feb 2020, EinExperte
Diese Seite läuft auf FoswikiDas Urheberrecht © liegt bei den mitwirkenden Autoren. Alle Inhalte dieser Kollaborationsplattform sind Eigentum der Autoren.
Ideen, Anfragen oder Probleme bezüglich bitmuehle wiki? Feedback senden