git.sr.ht/~pingoo/stdx@v0.0.0-20240218134121-094174641f6e/email/blocklist.go (about) 1 package email 2 3 import ( 4 "bufio" 5 "bytes" 6 _ "embed" 7 "strings" 8 ) 9 10 //go:embed domains_blocklist.txt 11 var BlocklistBytes []byte 12 13 var blocklist map[string]bool 14 15 func IsInBlocklist(email string) bool { 16 if blocklist == nil { 17 mailBlocklistFileReader := bytes.NewReader(BlocklistBytes) 18 mailBlocklistScanner := bufio.NewScanner(mailBlocklistFileReader) 19 blocklist := map[string]bool{} 20 21 for mailBlocklistScanner.Scan() { 22 blocklist[strings.TrimSpace(mailBlocklistScanner.Text())] = true 23 } 24 } 25 26 return blocklist[email] 27 }