linuxserver / docker-fail2ban

GNU General Public License v3.0
55 stars 7 forks source link

sendmail issue #9

Closed xolom closed 1 year ago

xolom commented 1 year ago

With the newest release I can't send mails anymore via sendmail. It gives me following error:

sendmail: Cannot open mail:25

Reproducable with: echo "Subject: sendmail test" | sendmail -v <email@address.com>

Arch: x86-64

docker-compose.yml:

fail2ban:
    container_name: fail2ban
    build:          fail2ban-dockerfile
    hostname:       xxxx
    restart:        always
    depends_on:
      - mysql
    cap_add:
      - NET_ADMIN
      - NET_RAW
    network_mode: host
    environment:
      - PUID=1000
      - PGID=1000
      - TZ=Europe/Vienna
    volumes:
      - ./fail2ban/config:/config
      - ./fail2ban/run:/var/run/fail2ban
      - /var/log:/var/log:ro
      - ./nextcloud/data/nextcloud.log:/remotelogs/nextcloud/nextcloud.log:ro
      - ./reverse-proxy/var/log/nginx:/remotelogs/reverse-proxy:ro
      - ./shared/fail2ban:/shared/fail2ban

Dockerfile:

FROM linuxserver/fail2ban:latest

RUN sed -i 's/ -vv//g' /etc/s6-overlay/s6-rc.d/svc-fail2ban/run

RUN apk update && apk add --no-cache python3 py3-pip mysql-dev
RUN pip3 install mysql-connector
github-actions[bot] commented 1 year ago

Thanks for opening your first issue here! Be sure to follow the bug or feature issue templates!

xolom commented 1 year ago

SSMTP was the culprit.

Removing it by adding

RUN apk del ssmtp

to my custom Dockerfile solved the issue

nemchik commented 1 year ago

So i'm looking at this and I see sendmail is normally provided by busybox, but can also be from dma, exim, opensmtpd, ssmtp and maybe others as well. In our case, ssmtp was not originally included, but was added in https://github.com/linuxserver/docker-fail2ban/pull/8 in response to being requested in https://github.com/linuxserver/docker-fail2ban/issues/6

You should actually be able to replace https://github.com/linuxserver/fail2ban-confs/blob/d0b2f029034feccad788debe468ed25690e23476/action.d/sendmail-common.conf#LL66C16-L66C29 with

mailcmd = /bin/busybox sendmail -f "<sender>" "<dest>"

and it should work without having to modify the image.

When installing ssmtp it appears to place a symlink at /usr/sbin/sendmail that just has it use ssmtp, so I would have expected the two to be compatible, but maybe it's not.

There's a few options to resolve this, but I'm not sure which one is the best choice at the moment.

github-actions[bot] commented 1 year ago

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.

github-actions[bot] commented 1 year ago

This issue is locked due to inactivity