Billionmail/BillionMail · error

invalid sender email format

Error message

invalid sender email format

What it means

validateAlertSettings performs a lightweight format check on SenderEmail — it must contain an '@' character. This is not a full RFC 5322 validation, but any value without '@' (or with only whitespace around it) is rejected before the alert settings are saved.

Source

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

	}

	err = gfile.PutContents(alertSettingsFile, string(jsonData))
	if err != nil {
		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")
	}

View on GitHub (pinned to fc36c76c05)

Solutions

  1. Provide a full address including domain, e.g. alerts@example.com
  2. Strip display-name formatting and send only the bare address
  3. Add stricter client-side validation (regex or HTML5 type=email) before submit
  4. Note the server check is only a Contains("@") — validate thoroughly on the client

Example fix

// before
{ "senderEmail": "Alert Bot <alerts@example.com>" }
// after
{ "senderEmail": "alerts@example.com" }
Defensive patterns

Strategy: validation

Validate before calling

const sender = (settings.senderEmail ?? '').trim();
if (!/^[^@\s]+@[^@\s]+\.[^@\s]+$/.test(sender)) throw new Error('invalid sender email format');

Type guard

function isEmailLike(v: unknown): v is string {
  return typeof v === 'string' && /^[^@\s]+@[^@\s]+$/.test(v);
}

Try / catch

try {
  await api.setBlacklistAlertSettings(settings);
} catch (e) {
  if (String(e.message).includes('invalid sender email format')) {
    notify('Enter a full email address, e.g. alerts@example.com');
  } else throw e;
}

Prevention

When it happens

Trigger: SenderEmail set to a bare username ('alerts'), a display name ('Alert Bot'), a value with spaces but no @, or an address missing the domain part ('alerts@').

Common situations: Users paste 'Name <alerts@example.com>' style headers, or enter just the local part assuming the domain is appended automatically.

Related errors


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