#4344·hertzbeat

HertzBeat fails to start when spring.mail is omitted (docs say optional)

Author: cursor[bot]Created Aug 24, 2026Updated Aug 24, 2026

Problem

Docs and sample application.yml / docker-compose configs describe spring.mail as optional (“not required if you don’t use email notify”). In practice, HertzBeat fails to start when spring.mail is omitted.

On apache/hertzbeat:1.8.0, startup dies with:

Parameter 0 of constructor in
org.apache.hertzbeat.alert.notice.impl.EmailAlertNotifyHandlerImpl
required a bean of type 'org.springframework.mail.javamail.JavaMailSender'
that could not be found.

EmailAlertNotifyHandlerImpl constructor-injects JavaMailSender. Spring Boot only auto-configures that bean when spring.mail.host (etc.) is set. No mail config → no bean → application context fails → process exits.

In Docker with restart: unless-stopped, this becomes a crash loop even when the only real notify path is webhook/Discord and email is never used.

Expected

  • No spring.mail → HertzBeat starts normally.
  • Email notify channels are unavailable (or clearly report “mail not configured”) until mail is set.
  • Behavior matches the documented “mail optional” story.

Actual

  • Missing spring.mail → fatal startup failure.
  • Workaround: add a dummy spring.mail block so JavaMailSender exists, even though nothing sends email.

Environment

  • Image: apache/hertzbeat:1.8.0
  • Notify: webhook/Discord only (no email)
  • Deploy: Docker Compose, custom application.yml mounted

Fix

PR: (will link after open)

Smoke-tested on DietPi at SHA 03956af9a87e9a2c214e9808e28f253edaf6bd8a with spring.mail fully omitted: healthy container, Restarts=0, clear email-not-configured error on test send, no JavaMailSender startup crash.