Direkt zum Hauptinhalt

Einrichten Emailversand mit Postfix

Damit auch Emailbenachrichtungen raus gehen, richten wir uns einen Postfix SMTP Server ein.
Abhängigkeiten installieren

apt-get install -y postfix bsd-mailx

NunInternet Site auswählen

Auswahl_836.png

Email Name ausfüllen: checkmk.local.lan

Auswahl_833.png

Nun den Emailempfänger für root eingeben.


Auswahl_837.png

weitere zeile, einfach so lassen

Auswahl_838.png

bei Synchrone Aktualiseirungen... Nein auswählen

Auswahl_839.png

Postfachgröße 0 einfach weiter klicken

Auswahl_841.png

Zeichen für Adresserweiterung

Auswahl_842.png

Alle auswählen

Auswahl_843.png

nun die Postfix datei /etc/postfix/main.cf öffnen

nano /etc/postfix/main.cf

Inhalt unter smtp_tls session diese 3 Zeilen einfügen

smtp_sasl_auth_enable = yes
smtp_sasl_password_maps = hash:/etc/postfix/sasl_passwd
smtp_sasl_security_options = noanonymous

Auswahl_834.png

Nun noch den relyhost anpassen. Bei mir ist es rs001871.fastrootserver.de

Auswahl_835.png

Nun die Password File anlegen

nano /etc/postfix/sasl_passwd

Inhalt, SMTP Host, Benutzername, Kennwort

[rs001871.fastrootserver.de]:587 monitoring@star-module.com *****

Nun die Password File eine Postmap draus machen

postmap /etc/postfix/sasl_passwd

Nun den Postfix-Server neustarten

service postfix restart

Testemail senden

 

echo "Dies ist eine Test E-Mail vom checkmk-Server" | mailx -s "Test" <ihre_notification_e-mail-adresse@gmail.com>
in der /var/log/mail.log kann man das ergebnis sehen.

hier ein Fehler beispiel, bei der Authentifizierung. Ganz am ende steht authetication failed. So weiß man, okay Kennwort falsch.

Nov 29 11:38:45 checkmk postfix/postfix-script[26039]: starting the Postfix mail system
Nov 29 11:38:45 checkmk postfix/master[26041]: daemon started -- version 3.5.13, configuration /etc/postfix
Nov 29 11:40:53 checkmk postfix/postfix-script[26644]: stopping the Postfix mail system
Nov 29 11:40:53 checkmk postfix/master[26041]: terminating on signal 15
Nov 29 11:40:54 checkmk postfix/postfix-script[27198]: starting the Postfix mail system
Nov 29 11:40:54 checkmk postfix/master[27200]: daemon started -- version 3.5.13, configuration /etc/postfix
Nov 29 11:41:10 checkmk postfix/pickup[27201]: A9F0D2075B: uid=0 from=<root>
Nov 29 11:41:10 checkmk postfix/cleanup[27249]: A9F0D2075B: message-id=<20221129104110.A9F0D2075B@checkmk.local.lan>
Nov 29 11:41:10 checkmk postfix/qmgr[27202]: A9F0D2075B: from=<root@checkmk.local.lan>, size=440, nrcpt=1 (queue active)
Nov 29 11:41:10 checkmk postfix/smtp[27251]: A9F0D2075B: to=<bonkersdeluxe@gmail.com>, relay=rs001871.fastrootserver.de[213.202.247.147]:25, delay=0.24, delays=0.02/0.02/0.21/0, dsn=4.7.8, status=deferred (SASL authentication failed; server rs001871.fastrootserver.de[213.202.247.147] said: 535 5.7.8 Error: authentication failed: authentication failure)

So sähe ein erfolgreicher Versand aus

Jan 20 09:46:00 checkmk postfix/pickup[594998]: 9077720BB6: uid=0 from=<root>
Jan 20 09:46:00 checkmk postfix/cleanup[603444]: 9077720BB6: message-id=<20230120084600.9077720BB6@checkmk.local.lan>
Jan 20 09:46:00 checkmk postfix/qmgr[1102]: 9077720BB6: from=<root@checkmk.local.lan>, size=440, nrcpt=1 (queue active)
Jan 20 09:46:00 checkmk postfix/smtp[603446]: 9077720BB6: to=<bonkersdeluxe@gmail.com>, relay=rs001871.fastrootserver.de[213.202.247.147]:25, delay=0.4, delays=0.01/0.01/0.35/0.03, dsn=5.7.1, status=bounced (host rs001871.fastrootserver.de[213.202.247.147] said: 554 5.7.1 <bonkersdeluxe@gmail.com>: Relay access denied (in reply to RCPT TO command))
Jan 20 09:46:01 checkmk postfix/cleanup[603444]: F40D520BD7: message-id=<20230120084600.F40D520BD7@checkmk.local.lan>
Jan 20 09:46:01 checkmk postfix/bounce[603447]: 9077720BB6: sender non-delivery notification: F40D520BD7
Jan 20 09:46:01 checkmk postfix/qmgr[1102]: F40D520BD7: from=<>, size=2542, nrcpt=1 (queue active)
Jan 20 09:46:01 checkmk postfix/qmgr[1102]: 9077720BB6: removed
Jan 20 09:46:01 checkmk postfix/local[603448]: F40D520BD7: to=<root@checkmk.local.lan>, relay=local, delay=0.02, delays=0/0.01/0/0.01, dsn=2.0.0, status=sent (delivered to mailbox)
Jan 20 09:46:01 checkmk postfix/qmgr[1102]: F40D520BD7: removed