Use it to validate email addresses on sign up, or just to see how many real email addresses you have in your system.
<repository>
<id>github</id>
<name>GitHub Packages</name>
<url>https://<github_user>:<github_personal_access_token>@maven.pkg.github.com/valarpirai/disposable-emails-validator-java</url>
</repository>
<dependency>
<groupId>org.valarpirai</groupId>
<artifactId>disposable-email</artifactId>
<version>{version}</version>
</dependency>
We are using an autogenerated list which is updated every 24 hours - https://github.com/disposable/disposable
This lib has a list of disposable email domains (encoded file) inside resources. The following method will download latest disposable email list from here and use it Note: In your application startup, you need to call this method to fetch updated domain list.
DisposableEmail.refreshDisposableDomains()
Get DNS and disposable details of a email domain. Response DomainDetails
domainDetails = DisposableEmail.getDomainDetails("gmail.com")
domainDetails.disposableDomain -> false
domainDetails.mxRecordPresent -> true
domainDetails = DisposableEmail.getDomainDetails("yopmail.com")
domainDetails.disposableDomain -> true
domainDetails.mxRecordPresent -> true
domainDetails = DisposableEmail.getDomainDetails("nonexisting123.com")
domainDetails.disposableDomain -> false
domainDetails.mxRecordPresent -> false
Check whether a given email address is disposable address (local check)
DisposableEmail.isDisposable("hello@gmail.com") -> false
DisposableEmail.isDisposable("hello@mailsac.com") -> true
Disposable domain with valid DNS MX Record
DisposableEmail.hasValidMailDomain("hello@mailsac.com") -> true
Valid domain without DNS MX Record
DisposableEmail.hasValidMailDomain("god.com") -> false
Use different DNS resolver
DisposableEmail.hasValidMailDomain("hello@gmail.com", DnsResolverType.CLOUD_FLARE) -> true
DisposableEmail.hasValidMailDomain("hello@gmail.com", DnsResolverType.GOOGLE) -> true
Whitelist Domains
DisposableEmail.addDomainToWhitelist("mailsac.com")
DisposableEmail.isDisposable("hello@mailsac.com") -> false
DisposableEmail.removeDomainFromWhitelist("mailsac.com")
DisposableEmail.isDisposable("mailsac.com") -> true
Blacklist Domains
DisposableEmail.addDomainToBlacklist("gmail.com")
DisposableEmail.isDisposable("hello@gmail.com") -> true
DisposableEmail.removeDomainFromBlacklist("gmail.com")
DisposableEmail.isDisposable("gmail.com") -> true
- We are using BloomFilter a space-efficient probabilistic data structure to store list of Disposable email domains
- This will work in offline mode.
- We are using DNS over HTTPS (DoH) to verify the MX Records
- CloudFlare (1.1.1.1) and Google(dns.google) DNS resolvers are support
- This will work in online mode. requires internet connection