{"record":{"id":"9b3feff0ab81fca7","repo":"knadh/listmonk","slug":"subscribers-domainblocklisted","errorCode":null,"errorMessage":"subscribers.domainBlocklisted","messagePattern":"subscribers\\.domainBlocklisted","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"warning","filePath":"internal/subimporter/importer.go","lineNumber":630,"sourceCode":"\taddr, err := utils.SanitizeEmail(email)\n\tif err != nil {\n\t\treturn \"\", errors.New(im.i18n.T(\"subscribers.invalidEmail\"))\n\t}\n\n\t// Check if the e-mail's domain is blocklisted. The e-mail domain and blocklist config\n\t// are always lowercase.\n\tif im.hasAllowlist || im.hasBlocklist {\n\t\td := strings.Split(addr, \"@\")\n\t\tif len(d) != 2 {\n\t\t\treturn addr, nil\n\t\t}\n\n\t\tdomain := d[1]\n\n\t\t// If there's an allowlist, check if the domain is in it. Checking blocklist after that is moot.\n\t\tif im.hasAllowlist {\n\t\t\tif !im.checkInList(domain, im.hasAllowlistWildcards, im.domainAllowlist) {\n\t\t\t\treturn \"\", errors.New(im.i18n.T(\"subscribers.domainBlocklisted\"))\n\t\t\t}\n\t\t} else if im.hasBlocklist {\n\t\t\tif im.checkInList(domain, im.hasBlocklistWildcards, im.domainBlocklist) {\n\t\t\t\treturn \"\", errors.New(im.i18n.T(\"subscribers.domainBlocklisted\"))\n\t\t\t}\n\t\t}\n\t}\n\n\treturn addr, nil\n}\n\n// ValidateFields validates incoming subscriber field values and returns sanitized fields.\nfunc (im *Importer) ValidateFields(s SubReq) (SubReq, error) {\n\tif len(s.Email) > 1000 {\n\t\treturn s, errors.New(im.i18n.T(\"subscribers.invalidEmail\"))\n\t}\n\n\tem, err := im.SanitizeEmail(s.Email)","sourceCodeStart":612,"sourceCodeEnd":648,"githubUrl":"https://github.com/knadh/listmonk/blob/670c01717d48647093335cc23a6be6f4b79c3b6b/internal/subimporter/importer.go#L612-L648","documentation":"SanitizeEmail enforces domain allowlist/blocklist rules configured in settings after validating the address syntax. If an allowlist exists and the email's domain is not in it, the import row is rejected with the localized message 'subscribers.domainBlocklisted'. Blocklist checking is moot when an allowlist is present since the allowlist is authoritative.","triggerScenarios":"ValidateFields imports a subscriber whose email domain (text after '@') fails im.checkInList against im.domainAllowlist because im.hasAllowlist is true and the domain (including wildcard patterns) does not match.","commonSituations":"Admin enables a domain allowlist (e.g. only company.com) then imports a list containing gmail.com addresses; subdomains like mail.company.com when only company.com without wildcards is allowlisted; punycode/IDN mismatches.","solutions":["Add the missing domains to the allowlist in Settings → Privacy, or use wildcard entries like *.company.com for subdomains.","Remove/disable the domain allowlist if you intend to import unrestricted external addresses.","Split the import: keep only allowlisted-domain rows and handle the rest separately.","Use wildcards in the allowlist when subdomains should be accepted."],"exampleFix":"// before (settings)\ndomain_allowlist = [\"company.com\"]\n// after\ndomain_allowlist = [\"company.com\", \"*.company.com\", \"gmail.com\"]","handlingStrategy":"validation","validationCode":"domain := strings.ToLower(email[strings.Index(email, \"@\")+1:])\nallowed := map[string]bool{\"company.com\": true, \"*.company.com\": true}\nallowedHere := false\nfor a := range allowed {\n    if ok, _ := path.Match(a, domain); ok { allowedHere = true; break }\n}\nif !allowedHere {\n    return fmt.Errorf(\"domain %s not in allowlist; row will be rejected\", domain)\n}","typeGuard":null,"tryCatchPattern":"em, err := importer.SanitizeEmail(email)\nif err != nil && err.Error() == im.i18n.T(\"subscribers.domainBlocklisted\") {\n    log.Printf(\"domain not allowed: %s\", domain)\n    continue\n}","preventionTips":["Review the configured domain allowlist before every bulk import.","Add wildcard entries when subdomains should pass.","Filter the CSV by domain against the allowlist before upload.","Don't mix allowlist intent with blocklist config — allowlist wins."],"tags":["email","import","allowlist","domain"],"backgroundTag":"domain-not-allowed","analyzedSha":"670c01717d48647093335cc23a6be6f4b79c3b6b","analyzedAt":"2026-09-01T03:39:35.452Z","contentChangedAt":null,"schemaVersion":2},"datasetVersion":"2026-09-08T10:18:20.063Z"}