diff --git a/backend/internal/services/notification_service.go b/backend/internal/services/notification_service.go index 0840f15..579d32e 100644 --- a/backend/internal/services/notification_service.go +++ b/backend/internal/services/notification_service.go @@ -4,6 +4,7 @@ import ( "context" "fmt" "log/slog" + "os" "os/exec" "strings" "sync" @@ -458,17 +459,25 @@ type UpdatePreferencesInput struct { } // SendEmail sends an email using the `m mail send` CLI command. +// In Docker, this will fail gracefully (m CLI not available). +// TODO: Replace with direct SMTP for production. func SendEmail(to, subject, body string) error { + from := os.Getenv("MAIL_FROM") + if from == "" { + from = "mgmt@msbls.de" + } cmd := exec.Command("m", "mail", "send", + "--from", from, "--to", to, "--subject", subject, "--body", body, "--yes") output, err := cmd.CombinedOutput() if err != nil { - return fmt.Errorf("m mail send failed: %w (output: %s)", err, string(output)) + slog.Warn("email send failed (m CLI may not be available in Docker)", "to", to, "error", err, "output", string(output)) + return fmt.Errorf("m mail send failed: %w", err) } - slog.Info("email sent", "to", to, "subject", subject) + slog.Info("email sent", "from", from, "to", to, "subject", subject) return nil }