This is a disposable email content verification tool package, implemented using the disposable-email-domains ↗ library provided by Github/Disposable ↗.
The aim is to provide a means of detecting temporary email services provided by providers such as 10MinuteMail ↗ , GuerrillaMail ↗ , and determining whether an email is a disposable email.
This tool can be used to verify whether the email address entered by users for login or registration is a temporary domain email, or to filter out existing temporary domain email addresses in the current system, for cleaning or other related processing.
<!-- ADD Maven Dependency -->
<dependency>
<groupId>com.zliio.disposable</groupId>
<artifactId>disposable</artifactId>
<version>1.0</version>
</dependency>
public class DisposableTest {
public static void main(String[] args) {
Disposable disposable = new Disposable();
System.out.println(disposable.validate("gmail.com"));
// True
System.out.println(disposable.validate("dsa@zliio.com"));
// True
System.out.println(disposable.validate("dsa@zliio.🤔️"));
// False
System.out.println(disposable.validate("test@0-mail.com"));
// False
}
}
You can set the black and white lists of email domains by configuring the domain-blacklist.txt and domain-whitelist.txt files under the resources directory of the project. Additionally, you can dynamically add or remove domains using methods like add* and remove* provided by the Disposable object instance.
To ensure the update of disposable-email-domains ↗, we also provide the refreshDisposableDomains() method in the Disposable object instance to obtain the latest configuration list. However, we do not recommend frequent calls to this method due to the relatively high cost and long execution time of updates. We suggest that you call this method once after creating the Disposable object instance to ensure the validity of the list.
Disposable disposable = new Disposable();
// Do refresh
disposable.refreshDisposableDomains();
When the update is successful, you will see the following message displayed in the console.
[main] INFO com.zliio.disposable.DomainsLibraryManager - DomainsLibraryManager :: Added : 54 Domain(s)
[main] INFO com.zliio.disposable.DomainsLibraryManager - DomainsLibraryManager :: Removed : 75 Domain(s)
For convenience, we provide separate solutions to validate email format, validate domain names, and validate disposable email addresses.
- TXT: https://disposable.github.io/disposable-email-domains/domains.txt
- JSON: https://disposable.github.io/disposable-email-domains/domains.json