emailverifier-kt is a powerful Kotlin library that goes beyond mere syntax checks to provide comprehensive email validation. It leverages coroutines for high performance, offering features like parallel initialization and verification, enabling developers to ensure that email addresses are real, valid, and worth accepting.
EmailVerifier is a composable, pluggable Kotlin library designed for validating email addresses with a focus that extends beyond basic syntax checks. This library assists developers in reliably determining whether an email address is genuine, meaningful, and suitable for acceptance.
EmailVerifier incorporates a multi-layered validation approach, which includes:
Syntax Validation
Validates the structure of an email according to RFC 5322, checking both the local-part format and hostname validity.
Registrability Check
Confirms whether an email's domain is registrable using the Public Suffix List, ensuring that invalid domains are flagged.
MX Record Lookup
Checks if the domain is configured to receive emails by querying DNS-over-HTTPS (DoH) with Google, returning MX records or indicating failure.
Disposable Email Detection
Identifies temporary or disposable email domains with curated lists from the disposable-email-domains repository, allowing specification of custom allow and deny sets.
Gravatar Existence Check
Determines if an email has an associated Gravatar by computing the email's MD5 hash, returning the Gravatar URL or a failure indication.
Free Email Provider Detection
Identifies whether the email domain belongs to a known free email provider, employing a curated list of common services.
Role-Based Username Detection
Validates whether the email username is generic or departmental (e.g., info@, admin@), consulting a list of common role-based usernames.
SMTP Deliverability Check
Conducts a live check with the mail server to verify mailbox existence using the RCPT TO command. This feature, while disabled by default, can be enabled and configured to function through a SOCKS proxy.
Offline Mode
Supports execution in a fully offline mode with bundled data for specific checks, while disabling others that require network access. Each check can also be configured individually for offline operation.
The validation results are structured in a data class, providing details for each check performed. Each check can yield results in one of four states: Passed, Failed, Skipped, or Errored, facilitating detailed error reporting and validation feedback.
To utilize EmailVerifier, developers can easily add it as a dependency in their Maven or Gradle project. Basic usage involves creating a verifier instance and invoking the verify method to assess the validity of an email address:
val verifier = emailVerifier { }
val result = verifier.verify("john.doe@example.com")
if (result.isLikelyDeliverable()) {
println("Valid email!")
} else {
println("Email validation failed: $result")
}
EmailVerifier provides extensive options for customizing checks, configuring data sources, and managing network options with a personalized HttpClient. This level of control allows developers to tailor the library to specific use cases and operational environments.
Ongoing development aims to introduce features such as typo check suggestions and multiplatform support, expanding the applicability of the library.
EmailVerifier stands out as a robust solution for developers seeking reliable email validation, incorporating sophisticated checks that enhance deliverability assessments.
No comments yet.
Sign in to be the first to comment.