Start free

Java Email Verification SDK — Verify Emails in Java

Everything you need to integrate email verification into your application.

Getting Started

The official Java SDK is on Maven Central, supports Java 11+, uses the built-in HTTP Client for zero dependencies, is fully thread-safe, and includes connection pooling.

Add the Maven dependency and verify with a type-safe builder pattern. Includes Spring Boot auto-configuration with @ValidEmail annotation. Visit our email verifier for web-based verification.

Code Example

<!-- Maven -->
<dependency>
  <groupId>org.emailvalidationtool</groupId>
  <artifactId>emailvalidationtool</artifactId>
  <version>1.0.0</version>
</dependency>

import org.emailvalidationtool.EmailValidator;
import org.emailvalidationtool.VerificationResult;

EmailValidationTool verifier = EmailValidationTool.builder()
    .apiKey("YOUR_API_KEY")
    .build();

VerificationResult result = verifier.verify("user@example.com");
System.out.println(result.getStatus());     // "deliverable"
System.out.println(result.getScore());      // 95
System.out.println(result.isDisposable());  // false

Authentication & Setup

Add the Maven or Gradle dependency. For Spring Boot, add the starter and configure ev.api-key in application.yml. The EmailValidationTool bean is auto-configured and thread-safe.

Getting Started

Add the Java email verification SDK to your project using Maven or Gradle. For Maven, add the org.emailvalidationtool:emailvalidationtool dependency to your pom.xml. For Gradle, add implementation 'org.emailvalidationtool:emailvalidationtool:1.0.0' to your build.gradle. The SDK requires Java 11 or higher and uses the built-in java.net.http.HttpClient for HTTP communication, keeping external dependencies to zero. It is published on Maven Central, so no additional repository configuration is needed.

Create an EmailValidationTool instance using the builder pattern. The builder accepts your API key, an optional timeout duration, retry configuration, sandbox mode toggle, and a custom base URL. The resulting client is fully thread-safe and uses connection pooling internally, so you should create a single instance and share it across your application. For Spring Boot projects, add the ev-spring-boot-starter dependency and set ev.api-key in your application.yml or application.properties. The starter auto-configures an EmailValidationTool bean that you can inject into any component using @Autowired.

Code Examples

Single Email Verification

import org.emailvalidationtool.EmailValidator;
import org.emailvalidationtool.VerificationResult;

public class VerifyExample {
    public static void main(String[] args) {
        EmailValidationTool verifier = EmailValidationTool.builder()
            .apiKey(System.getenv("EV_API_KEY"))
            .timeout(Duration.ofSeconds(30))
            .maxRetries(3)
            .build();

        VerificationResult result = verifier.verify("user@example.com");

        System.out.println("Email: " + result.getEmail());
        System.out.println("Status: " + result.getStatus());
        System.out.println("Score: " + result.getScore());
        System.out.println("Disposable: " + result.isDisposable());
        System.out.println("Role-based: " + result.isRoleBased());
        System.out.println("MX Found: " + result.isMxFound());
    }
}

Batch Email Verification

import org.emailvalidationtool.EmailValidator;
import org.emailvalidationtool.BatchJob;
import org.emailvalidationtool.BatchResult;
import java.util.List;

EmailValidationTool verifier = EmailValidationTool.builder()
    .apiKey("YOUR_API_KEY")
    .build();

List<String> emails = List.of(
    "alice@example.com", "bob@company.org", "test@temp-mail.io"
);

// Submit batch job
BatchJob job = verifier.verifyBatch(emails);
System.out.println("Job ID: " + job.getId());

// Wait for completion with polling
BatchResult batchResult = verifier.waitForBatch(job.getId(),
    Duration.ofSeconds(5),   // poll interval
    Duration.ofMinutes(10)   // timeout
);

// Process results
batchResult.getResults().forEach(r ->
    System.out.printf("%s: %s (score: %d)%n",
        r.getEmail(), r.getStatus(), r.getScore())
);

long validCount = batchResult.getResults().stream()
    .filter(r -> "deliverable".equals(r.getStatus()))
    .count();
System.out.println("Valid: " + validCount);

Spring Boot Integration

// application.yml
// ev:
//   api-key: ${EV_API_KEY}
//   timeout: 30s
//   sandbox: false

import org.emailvalidationtool.EmailValidator;
import org.emailvalidationtool.spring.ValidEmail;
import org.springframework.web.bind.annotation.*;

@RestController
public class RegistrationController {

    private final EmailValidationTool verifier;

    public RegistrationController(EmailValidationTool verifier) {
        this.verifier = verifier;
    }

    @PostMapping("/register")
    public ResponseEntity<?> register(
            @RequestParam @ValidEmail String email) {
        var result = verifier.verify(email);
        if (!"deliverable".equals(result.getStatus())) {
            return ResponseEntity.badRequest()
                .body("Please provide a valid email address.");
        }
        return ResponseEntity.ok("Registration successful");
    }
}

Error Handling

The Java SDK uses checked exceptions within the org.emailvalidationtool.exceptions package. The base exception EvException is extended by AuthenticationException for invalid API keys, RateLimitException for quota overages, ValidationException for malformed input, and NetworkException for connectivity issues. Each exception provides getStatusCode(), getErrorCode(), and getMessage() methods for programmatic error handling in your catch blocks.

The SDK automatically retries transient failures with exponential backoff. Configure retry behavior through the builder with maxRetries() and retryDelay(). The RateLimitException includes a getRetryAfter() method returning a Duration indicating the wait time. For batch operations, individual failures are captured in each result's getError() method rather than throwing exceptions. Use verifier.getRateLimitRemaining() to monitor your remaining quota. In Spring Boot applications, you can use @ExceptionHandler to map SDK exceptions to appropriate HTTP responses.

import org.emailvalidationtool.EmailValidator;
import org.emailvalidationtool.exceptions.*;

EmailValidationTool verifier = EmailValidationTool.builder()
    .apiKey("YOUR_API_KEY")
    .maxRetries(3)
    .build();

try {
    var result = verifier.verify("user@example.com");
    System.out.println("Status: " + result.getStatus());
} catch (RateLimitException e) {
    System.out.printf("Rate limited. Retry after %d seconds.%n",
        e.getRetryAfter().getSeconds());
} catch (AuthenticationException e) {
    System.err.println("Invalid API key. Check EV_API_KEY.");
} catch (ValidationException e) {
    System.err.println("Invalid input: " + e.getMessage());
} catch (EvException e) {
    System.err.printf("Error: %s (code: %s)%n",
        e.getMessage(), e.getErrorCode());
}

Frequently Asked Questions

The SDK supports Java 11 and above. It is available on Maven Central with groupId org.emailvalidationtool and artifactId emailvalidationtool. The SDK uses the Java HTTP Client (java.net.http) introduced in Java 11, requiring no additional HTTP dependencies.

Yes, the EmailValidationTool client is fully thread-safe and uses connection pooling internally. Create a single instance and share it across threads. The client handles concurrent requests efficiently with configurable pool sizes and timeout settings.

Yes, the SDK includes a Spring Boot auto-configuration module. Add the starter dependency, configure your API key in application.yml, and inject the EmailValidationTool bean. A custom @ValidEmail annotation is provided for bean validation.

Start Verifying Emails Today

100 daily free verifications. No credit card required. Full API access on all plans. Visit our email verifier to get started.

Try our free email verifier — verify any email instantly, no signup required. Need bulk verification? Upload your list and clean thousands of emails in minutes.

Developers: integrate email verification into your app with our RESTful API — SDKs for 7 languages.

Free tools: SPF checker · DKIM checker · SMTP tester