From 1fd2476d29144d31b784b4248cd92ce47da23b9f Mon Sep 17 00:00:00 2001 From: Simon Ser Date: Thu, 3 Aug 2023 14:16:31 +0000 Subject: [PATCH] server/email: log missing mail::error-to, treat empty string as unset Log a message when mail::error-to is unset, just in case the admin forgot to set it. Don't try to parse an email address if error-to is set to the empty string (the default value in the default config file). --- server/email.go | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/server/email.go b/server/email.go index 4cfa37be6396f7c7ed2a88db0cebc8d28dc1848e..2a403dd6801a23d0d600b5504f1b5f20344725c5 100644 --- a/server/email.go +++ b/server/email.go @@ -53,8 +53,9 @@ func EmailRecover(ctx context.Context, _origErr interface{}) error { config.ServiceName(ctx), origErr)) conf := config.ForContext(ctx) - to, ok := conf.Get("mail", "error-to") - if !ok { + to, _ := conf.Get("mail", "error-to") + if to == "" { + log.Println("Warning: mail::error-to is not set") return fmt.Errorf("internal system error") } rcpt, err := gomail.ParseAddress(to)