satellite/peer: better error handling for SMTP parameters
I tried to configure a satellite service and got this error: ``` DEBUG process/exec_conf.go:408 Unrecoverable error {"error": "missing port in address"} ``` It took some time to realize that I forgot to set the SMTPServerAddress. This patch makes it easier to detect similar problem (detailed error message), and makes SMTP parameters optional if no real mail sending is used (simulated or nomail) Change-Id: I32535a7c8d6529e19e4d919806f42ba430d074a5
This commit is contained in:
parent
4788b9ea3b
commit
788f5fde01
@ -11,6 +11,7 @@ import (
|
||||
|
||||
hw "github.com/jtolds/monkit-hw/v2"
|
||||
"github.com/spacemonkeygo/monkit/v3"
|
||||
"github.com/zeebo/errs"
|
||||
"go.uber.org/zap"
|
||||
|
||||
"storj.io/common/identity"
|
||||
@ -224,13 +225,13 @@ func setupMailService(log *zap.Logger, config Config) (*mailservice.Service, err
|
||||
// validate from mail address
|
||||
from, err := mail.ParseAddress(mailConfig.From)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
return nil, errs.New("SMTP from address '%s' couldn't be parsed: %v", mailConfig.From, err)
|
||||
}
|
||||
|
||||
// validate smtp server address
|
||||
host, _, err := net.SplitHostPort(mailConfig.SMTPServerAddress)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
if err != nil && mailConfig.AuthType != "simulate" && mailConfig.AuthType != "nologin" {
|
||||
return nil, errs.New("SMTP server address '%s' couldn't be parsed: %v", mailConfig.SMTPServerAddress, err)
|
||||
}
|
||||
|
||||
var sender mailservice.Sender
|
||||
|
Loading…
Reference in New Issue
Block a user