Billionmail/BillionMail · error

SMTP server is required

Error message

SMTP server is required

What it means

Validation guard inside validateAlertSettings: the blacklist alert settings request was saved with an empty SMTPServer field, so no mail relay host is available to send alert emails. The request is rejected before any settings are persisted.

Source

Thrown at core/internal/controller/settings/settings_v1_set_blacklist_alert_settings.go:76

		res.SetError(gerror.Newf(public.LangCtx(ctx, "Failed to save alert settings: {}", err.Error())))
		return res, nil
	}

	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)
		}

View on GitHub (pinned to fc36c76c05)

Solutions

  1. Provide the relay hostname, e.g. smtp.example.com or mail.example.com
  2. If the internal mail server should be used, set it explicitly to the local MX hostname (public.FormatMX(domain) result, e.g. mail.example.com)
  3. Make the field required in the UI and validate before submit
  4. Trim whitespace and reject blank values client-side

Example fix

// before
{ "smtpServer": "" }
// after
{ "smtpServer": "mail.example.com" }
Defensive patterns

Strategy: validation

Validate before calling

const server = (settings.smtpServer ?? '').trim();
if (!server) throw new Error('SMTP server is required');

Type guard

function hasSmtpServer(s: unknown): s is { smtpServer: string } {
  return typeof s === 'object' && s !== null && typeof (s as any).smtpServer === 'string' && (s as any).smtpServer.trim() !== '';
}

Try / catch

try {
  await api.setBlacklistAlertSettings(settings);
} catch (e) {
  if (String(e.message).includes('SMTP server is required')) {
    notify('SMTP relay host is required, e.g. mail.example.com');
    focusSmtpServerField();
  } else throw e;
}

Prevention

When it happens

Trigger: Calling SetBlacklistAlertSettings without smtpServer in the payload, with an empty string, or with only whitespace.

Common situations: Users leave the SMTP relay field blank expecting the local mail server to be used implicitly, or automation scripts omit the field when only updating the recipient list.

Understand the failure class

Background: "missing required argument" and "the following required arguments were not provided": what required-argument errors mean and how to fix them — this error's family across 20 libraries.

Related errors


AI-assisted analysis of Billionmail/BillionMail@fc36c76c05 (2026-09-05). Data as JSON: /api/errors/9b229ee64bffd7ea. Report an issue: GitHub.