{"record":{"id":"b25783244b9e53df","repo":"kataras/iris","slug":"s-mx-is-empty","errorCode":null,"errorMessage":"%s: mx is empty","messagePattern":"(.+?): mx is empty","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"macro/macros.go","lineNumber":454,"sourceCode":"\n\t// Email string type for validating an e-mail path parameter. It returns the address as string, instead of an *mail.Address.\n\t// It is a combined validation using mail.ParseAddress and net.LookupMX so only valid domains can be passed.\n\t// It's a more strictly version of the ':mail' path parameter.\n\tEmail = NewMacro(\"email\", \"\", \"\", false, false, func(paramValue string) (any, bool) {\n\t\t_, err := mail.ParseAddress(paramValue)\n\t\tif err != nil {\n\t\t\treturn fmt.Errorf(\"%s: %w\", paramValue, err), false\n\t\t}\n\n\t\tdomainPart := strings.Split(paramValue, \"@\")[1]\n\n\t\tmx, err := net.LookupMX(domainPart)\n\t\tif err != nil {\n\t\t\treturn fmt.Errorf(\"%s: %w\", paramValue, err), false\n\t\t}\n\n\t\tif len(mx) == 0 {\n\t\t\treturn fmt.Errorf(\"%s: mx is empty\", paramValue), false\n\t\t}\n\n\t\treturn paramValue, true\n\t})\n\n\tsimpleDateLayout = \"2006/01/02\"\n\n\t// Date type.\n\tDate = NewMacro(\"date\", \"\", time.Time{}, false, true, func(paramValue string) (any, bool) {\n\t\ttt, err := time.Parse(simpleDateLayout, paramValue)\n\t\tif err != nil {\n\t\t\treturn fmt.Errorf(\"%s: %w\", paramValue, err), false\n\t\t}\n\n\t\treturn tt, true\n\t})\n\n\t// ErrParamNotWeekday is fired when the parameter value is not a form of a time.Weekday.","sourceCodeStart":436,"sourceCodeEnd":472,"githubUrl":"https://github.com/kataras/iris/blob/7bedaf55a0b64bbb2248a5845a2c60d81a30996a/macro/macros.go#L436-L472","documentation":"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.","triggerScenarios":"Route {param:email} gets an address whose domain resolves in DNS but has zero MX records (LookupMX returns an empty, non-error slice).","commonSituations":"Domains that only have A records, parked domains, internal/corporate domains that route mail differently, or freshly registered domains without mail config.","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."],"exampleFix":"// before\n// GET /subscribe/{email:email} with /subscribe/user@domain-without-mx.tld\n\n// after\n// GET /subscribe/user@gmail.com  (domain publishes MX records)","handlingStrategy":"validation","validationCode":"mx, err := net.LookupMX(domain); if err == nil && len(mx) == 0 { /* domain has no MX records */ }","typeGuard":"func domainAcceptsMail(domain string) bool { mx, err := net.LookupMX(domain); return err == nil && len(mx) > 0 }","tryCatchPattern":null,"preventionTips":["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."],"tags":["go","iris","dns","mx-records","email-validation"],"backgroundTag":"missing-mx-records","analyzedSha":"7bedaf55a0b64bbb2248a5845a2c60d81a30996a","analyzedAt":"2026-08-30T20:38:16.250Z","schemaVersion":2},"datasetVersion":"2026-08-30T23:17:21.991Z"}