[BUG] SMTP listener now binds to EMAIL_PORT instead of 2525 since the gunicorn switch 5.0.3-ls373

Open Beginner friendly
#137 1 comment 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Assessment

Difficulty
2/5
Estimated time
1-3 hours
Newbie friendliness
72/100
Issue type
Bug
Clarity
Clearly specified
Activity status
Active
Tech stack
django, docker, dockerfile, python, shell

Research direction

The bug is in the s6 service run script at /etc/s6-overlay/s6-rc.d/svc-healthchecks-smtpd/run, which passes EMAIL_PORT to manage.py smtpd and sleeps when it is unset. Start there and check whether the inbound listener should read its own variable (such as SMTPD_PORT) with a default of 2525 instead. Done means the listener binds to 2525 with EMAIL_PORT set to 465, and starts when EMAIL_PORT is unset; verify with ps inside the container and a test email to port 25.

Written by the indexing model from the issue text.

Description

Is there an existing issue for this?
  • I have searched the existing issues
Current Behavior

Healthchecks sends outbound emails via Django's built-in SMTP email backend. I configure my SMTP relay with EMAIL_PORT = 465.

Since 5.0.3-ls373 (the "Switch to gunicorn" change), the incoming SMTP listener follows EMAIL_PORT instead of staying on 2525. This broke incoming emails until I changed my Compose port map from 25:2525 to 25:465.

If EMAIL_PORT isn't set at all, the listener doesn't even start (the run script falls through to sleep infinity), so anyone relying on inbound email without configuring outbound SMTP is also broken with this update.

Expected Behavior

The inbound SMTP listener should ignore the outbound SMTP settings, and shouldn't fail to start when the outbound SMTP port is not configured.

Suggested fix: define another variable (e.g. SMTPD_PORT) to define the inbound port, and fall back to default 2525 when not set.

Steps To Reproduce
  1. Run 5.0.3-ls373 or later with EMAIL_PORT=465 and -p 25:2525.
  2. Send an email ping to the container.
  3. The connection is refused. ps inside the container shows manage.py smtpd --port 465.
Environment
Docker Compose, x86_64, image lscr.io/linuxserver/healthchecks:latest at 5.0.3-ls373, via NixOS Docker module, managed by Komodo.
CPU architecture

x86-64

Docker creation
services:
  healthchecks:
    image: lscr.io/linuxserver/healthchecks:5.0.3-ls373
    restart: unless-stopped
    volumes:
      - /opt/docker/healthchecks:/config
    ports:
      - 25:2525  # worked before ls373; now needs 25:465
    environment:
      PUID: "1000"
      PGID: "1000"
      SITE_ROOT: "https://healthchecks.example.com"
      ALLOWED_HOSTS: "healthchecks.example.com"
      PING_EMAIL_DOMAIN: "healthchecks.example.com"
      DEFAULT_FROM_EMAIL: "[email protected]"
      EMAIL_HOST: "smtp.example.com"
      EMAIL_PORT: "465"
      EMAIL_HOST_USER: "[email protected]"
      EMAIL_HOST_PASSWORD: "<redacted>"
      EMAIL_USE_TLS: "False"
      EMAIL_USE_SSL: "True"
      SECRET_KEY: "<redacted>"
Container logs
$ docker exec healthchecks-healthchecks-1 ps aux | grep smtpd
root    42  ...  s6-supervise svc-healthchecks-smtpd
abc    178  ...  python3 ./manage.py smtpd --port 465

$ cat /etc/s6-overlay/s6-rc.d/svc-healthchecks-smtpd/run
#!/usr/bin/with-contenv bash
cd /app/healthchecks || exit 1
if [[ -n ${EMAIL_PORT} ]]; then
    exec s6-setuidgid abc python3 ./manage.py smtpd --port "${EMAIL_PORT}"
else
    sleep infinity
fi
Dominant language
Dockerfile
Stars
206
Forks
39
Avg merge
3h 45m
Merged PRs (30d)
1

Getting set up

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Similar issues

More DevOps issues

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.