I am trying to make fail2ban send me notifications when IP is banned. But I have troubles with configuring MTA
. It is a really tricky task.
I have tried multiple MTAs (mailx,exim ...) but I've failed to configure any of these clients, so I am back to sendmail.
I have personal domain mail server hosted on yandex
servers.
I create an account for sending mail from my server.
So here is my configuration for sendmail
MTA.
File /etc/mail/sendmail.mc
# Adding config for yandex (mydomain.net) #
define(`SMART_HOST',`[smtp.yandex.ru]')dnl
define(`RELAY_MAILER_ARGS', `TCP $h 465')dnl
define(`ESMTP_MAILER_ARGS', `TCP $h 465')dnl
define(`confAUTH_OPTIONS', `A p')dnl
TRUST_AUTH_MECH(`EXTERNAL DIGEST-MD5 CRAM-MD5 LOGIN PLAIN')dnl
define(`confAUTH_MECHANISMS', `EXTERNAL GSSAPI DIGEST-MD5 CRAM-MD5 LOGIN PLAIN')dnl
FEATURE(`authinfo',`hash -o /etc/mail/authinfo/yandex-auth.db')dnl
And when I try to send a mail message using this command
echo 'e-Mail TEST'| mail -s TEST [email protected]
I get following debug output
Apr 6 11:30:58 crosp sendmail[3138]: v36FUwxd003138: from=crosp, size=221, class=0, nrcpts=1, msgid=<[email protected]>, relay=root@localhost
Apr 6 11:30:58 crosp sendmail[3139]: v36FUwID003139: <[email protected]>... User unknown
Apr 6 11:30:58 crosp sendmail[3138]: v36FUwxd003138: [email protected], ctladdr=crosp (1000/1000), delay=00:00:00, xdelay=00:00:00, mailer=relay, pri=30221, relay=[127.0.0.1] [127.0.0.1], dsn=5.1.1, stat=User unknown
Apr 6 11:30:58 crosp sendmail[3139]: v36FUwID003139: from=<[email protected]>, size=221, class=0, nrcpts=0, proto=ESMTP, daemon=MTA, relay=localhost [127.0.0.1]
Apr 6 11:30:58 crosp sendmail[3138]: v36FUwxd003138: v36FUwxe003138: DSN: User unknown
Apr 6 11:30:58 crosp sendmail[3139]: v36FUwIF003139: from=<>, size=2026, class=0, nrcpts=1, msgid=<[email protected]>, proto=ESMTP, daemon=MTA, relay=localhost [127.0.0.1]
Apr 6 11:30:58 crosp sendmail[3138]: v36FUwxe003138: to=crosp, delay=00:00:00, xdelay=00:00:00, mailer=relay, pri=31245, relay=[127.0.0.1] [127.0.0.1], dsn=2.0.0, stat=Sent (v36FUwIF003139 Message accepted for delivery)
Apr 6 11:30:58 crosp sendmail[3140]: v36FUwIF003139: to=<[email protected]>, delay=00:00:00, xdelay=00:00:00, mailer=local, pri=32196, dsn=2.0.0, stat=Sent
What is wrong with my configuration ?
BTW If there are any other simpler way to configure fail2ban
mail notifications please let me know.
Thanks.
mydomain.net
listed on lists of (auto-configured) local email domains? As root executeecho '$=w' | sendmail -bt
to get list of local email domains (domains delivered to local mailboxes).