kataras/iris · error
: mx is empty
Error message
%s: mx is empty
What it means
After a successful MX lookup, the ':email' macro requires at least one MX record; an empty result means the domain exists but publishes no mail exchangers, so mail could not be delivered. The library rejects the parameter with this message naming the offending address.
Solutions
- Use a domain that actually publishes MX records if the address must be deliverable.
- Relax the route to {param:mail} or {param:email}... actually {param:mail} if MX presence should not be required.
- Verify with `dig MX <domain>` — empty answer section confirms the domain has no MX records.
Example fix
// before
// GET /subscribe/{email:email} with /subscribe/user@domain-without-mx.tld
// after
// GET /subscribe/user@gmail.com (domain publishes MX records) Defensive patterns
Strategy: validation
Validate before calling
mx, err := net.LookupMX(domain); if err == nil && len(mx) == 0 { /* domain has no MX records */ } Type guard
func domainAcceptsMail(domain string) bool { mx, err := net.LookupMX(domain); return err == nil && len(mx) > 0 } Prevention
- Check `dig MX <domain>` for domains you expect to accept.
- Use :mail macro if MX presence should not be mandatory.
- Treat this as a data-quality signal — the address domain is not set up for mail.
When it happens
Trigger: Route {param:email} gets an address whose domain resolves in DNS but has zero MX records (LookupMX returns an empty, non-error slice).
Common situations: Domains that only have A records, parked domains, internal/corporate domains that route mail differently, or freshly registered domains without mail config.
Related errors
- build: inject live reload: failed
- build: router
- build: view engine
- build
- context: read body: cannot bind multipart/related: use…
AI-assisted analysis of kataras/iris@7bedaf55a0 (2026-08-30).
Data as JSON: /api/errors/b25783244b9e53df.
Report an issue: GitHub.
Appendix: source
Thrown at macro/macros.go:454
// Email string type for validating an e-mail path parameter. It returns the address as string, instead of an *mail.Address.
// It is a combined validation using mail.ParseAddress and net.LookupMX so only valid domains can be passed.
// It's a more strictly version of the ':mail' path parameter.
Email = NewMacro("email", "", "", false, false, func(paramValue string) (any, bool) {
_, err := mail.ParseAddress(paramValue)
if err != nil {
return fmt.Errorf("%s: %w", paramValue, err), false
}
domainPart := strings.Split(paramValue, "@")[1]
mx, err := net.LookupMX(domainPart)
if err != nil {
return fmt.Errorf("%s: %w", paramValue, err), false
}
if len(mx) == 0 {
return fmt.Errorf("%s: mx is empty", paramValue), false
}
return paramValue, true
})
simpleDateLayout = "2006/01/02"
// Date type.
Date = NewMacro("date", "", time.Time{}, false, true, func(paramValue string) (any, bool) {
tt, err := time.Parse(simpleDateLayout, paramValue)
if err != nil {
return fmt.Errorf("%s: %w", paramValue, err), false
}
return tt, true
})
// ErrParamNotWeekday is fired when the parameter value is not a form of a time.Weekday.View on GitHub (pinned to 7bedaf55a0)