validateEmail method

Future<SingleValidationResponse> validateEmail(
  1. String email
)

Validates a single email address.

Performs comprehensive validation including syntax checking, domain verification, MX record validation, SMTP verification, disposable email detection, and risk assessment.

The validation result is cached, so subsequent requests for the same email (by the same user) will not consume credits.

email The email address to validate. Will be normalized (lowercased and trimmed).

Returns a SingleValidationResponse containing detailed validation results.

Throws an ApiException if:

  • The API key is invalid (401)
  • Insufficient credits (402)
  • Network or server errors occur

Example:

try {
  final result = await client.validateEmail('user@example.com');
  if (result.isValid && !result.disposable) {
    print('Email is valid and deliverable');
  } else {
    print('Email validation failed: ${result.risk} risk');
  }
} on ApiException catch (e) {
  print('API Error: ${e.message}');
}

Implementation

Future<SingleValidationResponse> validateEmail(String email) async {
  final request = SingleValidationRequest(email: email);
  return _request<SingleValidationResponse>(
    'POST',
    '/api/v1/validate',
    request.toJson(),
    (json) => SingleValidationResponse.fromJson(json),
  );
}