Sign Up Free

C# Email Verification SDK — Verify Emails in .NET

Everything you need to integrate email verification into your application.

Getting Started

The official C# SDK targets .NET Standard 2.1 and supports .NET 6, 7, and 8. Uses HttpClient with IHttpClientFactory for proper connection lifecycle management.

Install via NuGet and verify with async/await patterns. Provides IServiceCollection extensions for DI and ASP.NET Core integration with a custom validation attribute. Visit our email verifier for no-code verification.

Code Example

dotnet add package EV.EmailVerifier

using EV.EmailVerifier;

var verifier = new EmailVerifierClient("YOUR_API_KEY");
var result = await verifier.VerifyAsync("user@example.com");

Console.WriteLine(result.Status);      // "deliverable"
Console.WriteLine(result.Score);       // 95
Console.WriteLine(result.IsDisposable); // false

// ASP.NET Core DI setup (Program.cs)
builder.Services.AddEmailVerifier(options =>
    options.ApiKey = builder.Configuration["EV:ApiKey"]
);

Authentication & Setup

Install: dotnet add package EV.EmailVerifier. For ASP.NET Core, call services.AddEmailVerifier() in Program.cs. Configure API key in appsettings.json under EV:ApiKey.

Getting Started

Install the C# email verification SDK by running dotnet add package EV.EmailVerifier in your project directory. The package targets .NET Standard 2.1, making it compatible with .NET 6, 7, 8, and later versions. It uses HttpClient with IHttpClientFactory support for proper connection lifecycle management, avoiding socket exhaustion in long-running applications. The package is available on NuGet and can also be installed through the Visual Studio NuGet Package Manager or by adding a PackageReference to your .csproj file.

After installation, create an EmailVerifierClient instance with your API key. For ASP.NET Core applications, call builder.Services.AddEmailVerifier() in your Program.cs and configure the API key in appsettings.json under the EV:ApiKey section. The service registration uses IHttpClientFactory internally for optimal connection management. The options object supports Timeout, MaxRetries, Sandbox mode, and a custom BaseUrl. All verification methods are fully asynchronous, returning Task<T> and supporting CancellationToken parameters for cooperative cancellation throughout your application pipeline.

Code Examples

Single Email Verification

using EV.EmailVerifier;

var verifier = new EmailVerifierClient(
    Environment.GetEnvironmentVariable("EV_API_KEY"));

var result = await verifier.VerifyAsync("user@example.com");

Console.WriteLine($"Email: {result.Email}");
Console.WriteLine($"Status: {result.Status}");
Console.WriteLine($"Score: {result.Score}");
Console.WriteLine($"Disposable: {result.IsDisposable}");
Console.WriteLine($"Role-based: {result.IsRoleBased}");
Console.WriteLine($"MX Found: {result.MxFound}");
Console.WriteLine($"Provider: {result.SmtpProvider}");

Batch Email Verification

using EV.EmailVerifier;

var verifier = new EmailVerifierClient("YOUR_API_KEY");

var emails = new List<string>
{
    "alice@example.com", "bob@company.org", "test@temp-mail.io"
};

// Submit batch job
var job = await verifier.VerifyBatchAsync(emails);
Console.WriteLine($"Job ID: {job.Id}, Status: {job.Status}");

// Wait for completion with built-in polling
var results = await verifier.WaitForBatchAsync(job.Id,
    pollInterval: TimeSpan.FromSeconds(5),
    timeout: TimeSpan.FromMinutes(10));

// Process results
foreach (var result in results)
{
    Console.WriteLine($"{result.Email}: {result.Status} (score: {result.Score})");
}

var validCount = results.Count(r => r.Status == "deliverable");
Console.WriteLine($"Valid: {validCount}, Total: {results.Count}");

ASP.NET Core Dependency Injection

// Program.cs
builder.Services.AddEmailVerifier(options =>
{
    options.ApiKey = builder.Configuration["EV:ApiKey"];
    options.Timeout = TimeSpan.FromSeconds(30);
    options.MaxRetries = 3;
});

// Controller
using EV.EmailVerifier;
using Microsoft.AspNetCore.Mvc;

[ApiController]
[Route("api/[controller]")]
public class RegistrationController : ControllerBase
{
    private readonly IEmailVerifier _verifier;

    public RegistrationController(IEmailVerifier verifier)
    {
        _verifier = verifier;
    }

    [HttpPost]
    public async Task<IActionResult> Register(
        [FromBody] RegisterRequest request,
        CancellationToken cancellationToken)
    {
        var result = await _verifier.VerifyAsync(
            request.Email, cancellationToken);

        if (result.Status != "deliverable")
            return BadRequest("Please use a valid email address.");

        return Ok("Registration successful");
    }
}

Error Handling

The C# SDK throws specific exception types within the EV.EmailVerifier.Exceptions namespace. The base class EvException is extended by AuthenticationException for invalid or expired API keys, RateLimitException for quota overages with a RetryAfter property of type TimeSpan, ValidationException for malformed email addresses, and NetworkException for connectivity issues. Each exception includes StatusCode, ErrorCode, and Message properties for programmatic handling.

The SDK automatically retries transient failures with exponential backoff, including 429 rate limit responses and 5xx server errors. Configure retry behavior through the MaxRetries and RetryDelay options. All async methods accept an optional CancellationToken, which is respected during retries. For batch operations, individual email failures are captured in each result's Error property without throwing exceptions. Use verifier.RateLimitRemaining to monitor your remaining request quota. In ASP.NET Core, you can use middleware or an exception filter to map SDK exceptions to appropriate HTTP responses automatically.

using EV.EmailVerifier;
using EV.EmailVerifier.Exceptions;

var verifier = new EmailVerifierClient("YOUR_API_KEY",
    new VerifierOptions { MaxRetries = 3 });

try
{
    var result = await verifier.VerifyAsync("user@example.com");
    Console.WriteLine($"Status: {result.Status}");
}
catch (RateLimitException ex)
{
    Console.WriteLine($"Rate limited. Retry after {ex.RetryAfter.TotalSeconds}s.");
    await Task.Delay(ex.RetryAfter);
}
catch (AuthenticationException)
{
    Console.Error.WriteLine("Invalid API key. Check EV:ApiKey config.");
}
catch (ValidationException ex)
{
    Console.Error.WriteLine($"Invalid input: {ex.Message}");
}
catch (EvException ex)
{
    Console.Error.WriteLine($"Error: {ex.Message} (code: {ex.ErrorCode})");
}

Frequently Asked Questions

The SDK targets .NET Standard 2.1 and supports .NET 6, .NET 7, and .NET 8. Install via NuGet with dotnet add package EV.EmailVerifier. The SDK uses HttpClient with IHttpClientFactory support for proper connection management.

Yes, the SDK provides extension methods for IServiceCollection. Call services.AddEmailVerifier(options => options.ApiKey = "YOUR_KEY") in your Startup.cs or Program.cs. The SDK registers as a singleton with proper HttpClient lifecycle management.

Yes, the SDK includes ASP.NET Core integration with a custom [EmailVerification] validation attribute, middleware for request-level email validation, and health check support. It works with both MVC controllers and minimal APIs.

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