Billionmail/BillionMail · error
SMTP port must be between 1 and 65535
Error message
SMTP port must be between 1 and 65535
What it means
validateAlertSettings rejects blacklist alert SMTP settings whose port is outside the valid TCP range. SMTPPort must be an integer from 1 to 65535; anything below 1 (typically the zero-value of an unset field) or above 65535 fails validation before any connection is attempted.
Source
Thrown at core/internal/controller/settings/settings_v1_set_blacklist_alert_settings.go:80
res.SetSuccess(public.LangCtx(ctx, "Alert settings saved successfully and test email sent"))
return res, nil
}
func validateAlertSettings(settings *v1.SetBlacklistAlertSettingsReq) error {
if settings.SenderEmail == "" {
return fmt.Errorf("sender email is required")
}
if !strings.Contains(settings.SenderEmail, "@") {
return fmt.Errorf("invalid sender email format")
}
if settings.SMTPServer == "" {
return fmt.Errorf("SMTP server is required")
}
if settings.SMTPPort < 1 || settings.SMTPPort > 65535 {
return fmt.Errorf("SMTP port must be between 1 and 65535")
}
if settings.SMTPPassword == "" {
return fmt.Errorf("SMTP password is required")
}
if len(settings.RecipientList) == 0 {
return fmt.Errorf("at least one recipient is required")
}
for _, recipient := range settings.RecipientList {
if !strings.Contains(recipient, "@") {
return fmt.Errorf("invalid recipient email format: %s", recipient)
}
}
return nil
}View on GitHub (pinned to fc36c76c05)
Solutions
- Set SMTPPort to the actual SMTP server port (e.g. 587 for STARTTLS, 465 for implicit TLS, 25 for relay).
- Ensure the JSON request field is a number, not a string, and is explicitly included in the payload.
- If port is optional, default it server-side to 587 before calling validateAlertSettings.
Example fix
// before
{"smtpServer":"smtp.example.com","smtpPort":0,...}
// after
{"smtpServer":"smtp.example.com","smtpPort":587,...} Defensive patterns
Strategy: validation
Validate before calling
const port = Number(payload.smtpPort)
if (!Number.isInteger(port) || port < 1 || port > 65535) {
throw new Error(`smtpPort must be an integer 1-65535, got ${payload.smtpPort}`)
} Type guard
function isValidPort(p: unknown): p is number {
return typeof p === 'number' && Number.isInteger(p) && p >= 1 && p <= 65535
} Prevention
- Always send smtpPort as an explicit number in the API payload
- Default to 587 (STARTTLS) or 465 (implicit TLS) in the UI form
- Never rely on zero-values for required numeric fields
When it happens
Trigger: Calling SetBlacklistAlertSettings with SMTPPort=0 (field omitted in the JSON payload, so GoStruct zero-value), a negative number, or a value >65535.
Common situations: Client omits smtpPort in the request body; frontend sends the port as a string so it fails to bind and stays 0; a typo like 655360; admin pastes a URL instead of a port.
Related errors
- SMTP password is required
- at least one recipient is required
- hostname format is incorrect
- port must be between 1-65535
- IPv4 network format is incorrect, please use CIDR format (e.
AI-assisted analysis of Billionmail/BillionMail@fc36c76c05 (2026-09-05).
Data as JSON: /api/errors/ea97b515e9208900.
Report an issue: GitHub.