From 4fdd37c745c436236091f5d8e48dc8216abdbe23 Mon Sep 17 00:00:00 2001 From: Chris Dzombak Date: Wed, 25 Oct 2023 10:43:42 -0400 Subject: [PATCH] move smtp port validation --- main.go | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/main.go b/main.go index dc2c30b..a74d81b 100644 --- a/main.go +++ b/main.go @@ -278,14 +278,15 @@ func main() { } } } - if mailCfg.smtpPort < 1 || mailCfg.smtpPort > 65535 { - mailCfg.smtpPort = 25 - runCfg.outputConfig.addSetupWarning(fmt.Sprintf( - "Invalid SMTP port %d given; using default of 25 instead", mailCfg.smtpPort)) - } if mailCfg.mailTo != "" && strings.Contains(mailCfg.mailTo, "@") { if *smtpUser != "" || *smtpPass != "" || *smtpHost != "" { shouldMailOutput = true + + if mailCfg.smtpPort < 1 || mailCfg.smtpPort > 65535 { + runCfg.outputConfig.addSetupWarning(fmt.Sprintf( + "Invalid SMTP port %d given; using default of 25 instead", mailCfg.smtpPort)) + mailCfg.smtpPort = 25 + } } else { runCfg.outputConfig.addSetupWarning(fmt.Sprintf( "If using -mailto (or the %s env var), you must also specify -smtp-user (%s), -smtp-pass (%s), -smtp-host (%s).",