Skip to content

Commit

Permalink
move smtp port validation
Browse files Browse the repository at this point in the history
  • Loading branch information
cdzombak committed Oct 25, 2023
1 parent 7394d4a commit 4fdd37c
Showing 1 changed file with 6 additions and 5 deletions.
11 changes: 6 additions & 5 deletions main.go
Original file line number Diff line number Diff line change
Expand Up @@ -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).",
Expand Down

0 comments on commit 4fdd37c

Please sign in to comment.