diff --git a/pkg/email/config.go b/pkg/email/config.go index b11bc65..ddaa08b 100644 --- a/pkg/email/config.go +++ b/pkg/email/config.go @@ -3,6 +3,7 @@ package email import ( "fmt" "os" + "strings" "github.com/emersion/go-imap/client" "github.com/joho/godotenv" @@ -44,8 +45,21 @@ func NewConfigFromEnv() (*Config, error) { fetchServer = os.Getenv("IMAP_SERVER") sendServer = os.Getenv("SMTP_SERVER") - if len(username) == 0 || len(password) == 0 || len(fetchServer) == 0 || len(sendServer) == 0 { - return nil, fmt.Errorf("missing configuration variables") + var missing []string + if len(username) == 0 { + missing = append(missing, "EMAIL_USERNAME") + } + if len(password) == 0 { + missing = append(missing, "EMAIL_PASSWORD") + } + if len(fetchServer) == 0 { + missing = append(missing, "IMAP_SERVER") + } + if len(sendServer) == 0 { + missing = append(missing, "SMTP_SERVER") + } + if len(missing) > 0 { + return nil, fmt.Errorf("missing configuration variables: %s", strings.Join(missing, ", ")) } return NewConfig(username, password, fetchServer, sendServer), nil