Liking cljdoc? Tell your friends :D

bouncelens-email-check (Clojure)

Clojars Project

Clojure library that checks email addresses before you send to them or save them:

  • Typos in the domain: jane@gmial.com → did you mean jane@gmail.com?
  • Disposable / throwaway domains (~9,000 built in)
  • Dead domains: the domain doesn't exist, has no mail server, or accepts no email (null MX)
  • Bad syntax, role addresses (info@, sales@), free providers, duplicates (Gmail dot and +tag variants count as the same inbox)
  • The mail provider behind the domain (Google, Microsoft, Proofpoint, …)

No API key, no account. It's the Clojure version of the free checker at bouncelens.com and returns the same results.

It never connects to the recipient's mail server, so it can't confirm that a mailbox exists. The best status is :unconfirmed (format and domain OK).

Install

;; deps.edn
net.clojars.akshaycu777/bouncelens-email-check {:mvn/version "1.0.0"}
;; Leiningen
[net.clojars.akshaycu777/bouncelens-email-check "1.0.0"]

Use

(require '[bouncelens.email-check :as ec])

(ec/check-one "jane@gmial.com")
;; => {:status :risky, :did-you-mean "jane@gmail.com",
;;     :reasons ["..." "Looks like a typo of gmail.com"], :flags {...}, ...}

(def results (ec/check ["jane@gmail.com" "temp@mailinator.com" "Jane@Gmail.com"]))
(ec/summarize results)
;; => {:total 3, :unconfirmed 1, :risky 1, :duplicates 1, ...}
:statusMeaning
:invalidWill bounce: bad syntax, domain doesn't exist, no mail server, or null MX
:riskyDisposable domain, likely typo, no MX record, non-English characters before @, or the DNS lookup failed
:unconfirmedFormat and domain OK. The mailbox itself isn't checked

Options for check: :concurrency (domains looked up at once, default 8), :disposable (your own set), :lookup ((fn [domain] -> info), e.g. a cached resolver).

Each unique domain is looked up once per call. Only the domain is sent to Cloudflare's DNS-over-HTTPS resolver (1.1.1.1). Requires Java 11+.

Tests

lein test

Offline: test-resources/dns.json holds recorded DNS answers and golden.json the BounceLens JavaScript engine's results for the same inputs; the Clojure code must match them exactly.

More from BounceLens

License

MIT. Disposable-domain list: disposable-email-domains (CC0).

Can you improve this documentation?Edit on GitHub

cljdoc builds & hosts documentation for Clojure/Script libraries

Keyboard shortcuts
Ctrl+kJump to recent docs
←Move to previous article
→Move to next article
Ctrl+/Jump to the search field
× close