EmailDomainValidator 2.0.0.62

dotnet add package EmailDomainValidator --version 2.0.0.62
                    
NuGet\Install-Package EmailDomainValidator -Version 2.0.0.62
                    
This command is intended to be used within the Package Manager Console in Visual Studio, as it uses the NuGet module's version of Install-Package.
<PackageReference Include="EmailDomainValidator" Version="2.0.0.62" />
                    
For projects that support PackageReference, copy this XML node into the project file to reference the package.
<PackageVersion Include="EmailDomainValidator" Version="2.0.0.62" />
                    
Directory.Packages.props
<PackageReference Include="EmailDomainValidator" />
                    
Project file
For projects that support Central Package Management (CPM), copy this XML node into the solution Directory.Packages.props file to version the package.
paket add EmailDomainValidator --version 2.0.0.62
                    
#r "nuget: EmailDomainValidator, 2.0.0.62"
                    
#r directive can be used in F# Interactive and Polyglot Notebooks. Copy this into the interactive tool or source code of the script to reference the package.
#:package EmailDomainValidator@2.0.0.62
                    
#:package directive can be used in C# file-based apps starting in .NET 10 preview 4. Copy this into a .cs file before any lines of code to reference the package.
#addin nuget:?package=EmailDomainValidator&version=2.0.0.62
                    
Install as a Cake Addin
#tool nuget:?package=EmailDomainValidator&version=2.0.0.62
                    
Install as a Cake Tool

EmailDomainValidator

A lightweight, free .NET library for validating email addresses — checking format, detecting disposable domains, and verifying real MX records.


Key Features

  • Email Format Validation — regex-based format check (user@domain.com)
  • Disposable Email Detection — blocks known throwaway domains (5,400+ entries, embedded at build time)
  • Real MX Record Verification — uses actual DNS MX queries via DnsClient.NET, not just A-record resolution
  • Rich Validation ResultsValidationResult tells you why an email failed (InvalidFormat, DisposableDomain, NoMxRecords)
  • Dependency Injection Support — register via services.AddEmailDomainValidator() or use the static API
  • Configurable Options — tune cache TTL and blocklist update URL via EmailValidatorOptions
  • Blocklist Update Mechanism — refresh the in-memory blocklist at runtime from any URL, no restart required
  • Async Support — every method has an async counterpart
  • MX Result Caching — DNS lookups are cached (default: 1 hour) to avoid redundant queries

Installation

dotnet add package EmailDomainValidator

Quick Start

Static API

using EmailDomainValidator;

// Simple bool check
bool isValid = EmailValidator.ValidateEmail("user@example.com");

// Async
bool isValid = await EmailValidator.ValidateEmailAsync("user@example.com");

// Detailed result — know exactly why validation failed
ValidationResult result = EmailValidator.ValidateEmailWithResult("user@mailinator.com");
// result.IsValid        -> false
// result.FailureReason  -> ValidationFailureReason.DisposableDomain

// Implicit bool conversion
if (!result) Console.WriteLine($"Rejected: {result.FailureReason}");

Dependency Injection (ASP.NET Core / Generic Host)

// Program.cs
builder.Services.AddEmailDomainValidator();

// Or with custom options
builder.Services.AddEmailDomainValidator(options =>
{
    options.CacheTtl = TimeSpan.FromMinutes(30);
});
// In a controller, service, etc.
public class RegistrationService(IEmailDomainValidator validator)
{
    public async Task RegisterAsync(string email)
    {
        var result = await validator.ValidateEmailWithResultAsync(email);
        if (!result)
            throw new ArgumentException($"Invalid email: {result.FailureReason}");
        // ...
    }
}

API Reference

EmailValidator (static class) / IEmailDomainValidator (interface)

Method Returns Description
IsValidFormat(email) bool Regex format check
IsDisposableEmail(email) bool Checks against embedded blocklist
HasValidMxRecords(email) bool Real DNS MX query (sync)
HasValidMxRecordsAsync(email) Task<bool> Real DNS MX query (async)
ValidateEmail(email) bool All checks combined (sync)
ValidateEmailAsync(email) Task<bool> All checks combined (async)
ValidateEmailWithResult(email) ValidationResult All checks, with failure reason (sync)
ValidateEmailWithResultAsync(email) Task<ValidationResult> All checks, with failure reason (async)
UpdateBlocklistAsync(url) Task Fetch a fresh blocklist from a URL at runtime

ValidationResult

result.IsValid        // bool
result.FailureReason  // ValidationFailureReason enum
(bool)result          // implicit conversion
result.ToString()     // "Valid" or "Invalid: DisposableDomain"

ValidationFailureReason values: None, InvalidFormat, DisposableDomain, NoMxRecords

EmailValidatorOptions

new EmailValidatorOptions
{
    CacheTtl = TimeSpan.FromHours(1),   // how long MX results are cached
    BlocklistUpdateUrl = null            // optional URL for runtime blocklist refresh
}

Disposable Email Blocklist

The embedded blocklist ships with 5,400+ known disposable domains and is sourced from the community-maintained disposable-email-domains project.

Since new disposable providers appear regularly, the library provides a runtime update mechanism so your application can refresh the list without a redeployment:

// Refresh at startup or on a schedule
await EmailValidator.UpdateBlocklistAsync(
    "https://raw.githubusercontent.com/disposable-email-domains/disposable-email-domains/master/disposable_email_blocklist.conf"
);

The new list is swapped in atomically — no downtime, no restart.


Dependencies

Package Purpose
DnsClient Real DNS MX record queries
Microsoft.Extensions.Caching.Memory MX result caching
Microsoft.Extensions.DependencyInjection DI registration support
Microsoft.Extensions.Http HttpClient for blocklist updates

Use Cases

  • User Registration — block fake/throwaway accounts at sign-up
  • Newsletter Subscriptions — keep mailing lists clean
  • E-commerce — reduce fraud and improve delivery rates
  • Lead Generation — validate form submissions before they hit your CRM
  • Data Cleaning — validate existing email datasets in bulk

Contributing

Contributions are welcome. Please fork the repository, make your changes on a feature branch, and open a pull request. For significant changes, open an issue first.


License

MIT — see LICENSE for details.


Product Compatible and additional computed target framework versions.
.NET net10.0 is compatible.  net10.0-android was computed.  net10.0-browser was computed.  net10.0-ios was computed.  net10.0-maccatalyst was computed.  net10.0-macos was computed.  net10.0-tvos was computed.  net10.0-windows was computed. 
Compatible target framework(s)
Included target framework(s) (in package)
Learn more about Target Frameworks and .NET Standard.

NuGet packages

This package is not used by any NuGet packages.

GitHub repositories

This package is not used by any popular GitHub repositories.

Version Downloads Last Updated
2.0.0.62 101 4/30/2026
2.0.0.59 91 4/29/2026
1.0.0.56 97 4/29/2026
1.0.0.52 88 4/29/2026
1.0.0.50 456 1/12/2026
1.0.0.48 700 4/30/2025
1.0.0.45 508 3/14/2025
1.0.0.43 197 3/14/2025
1.0.0.39 202 3/14/2025
1.0.0.37 211 3/14/2025
1.0.0.35 318 3/6/2025
1.0.0.31 270 3/6/2025
1.0.0.11 284 3/5/2025
1.0.0.10 280 3/5/2025
1.0.0.9 262 3/5/2025
1.0.0.8 277 3/5/2025
1.0.0 262 3/5/2025