⚠️ DISCLAIMER: This is NOT an official NeverBounce package. This is a community-maintained .NET client library created by HYMMA. For official SDKs and support, please visit NeverBounce.
A modern .NET 8 client library for the NeverBounce email validation API. Validate email addresses before sending to reduce bounces and protect your sender reputation.
- Single Email Validation - Validate individual email addresses in real-time
- Comprehensive Results - Get detailed validation status, flags, and typo suggestions
- Dependency Injection - Easy integration with ASP.NET Core and .NET Generic Host
- Configurable - Customize timeouts, error handling, and more
- Well Tested - Comprehensive unit test coverage
- Modern .NET - Built for .NET 8 with nullable reference types
dotnet add package Hymma.NeverBouncedotnet pack -c Release
dotnet add package Hymma.NeverBounce --source ./src/Hymma.NeverBounce/bin/Release// In Program.cs or Startup.cs
// Option 1: With API key directly
builder.Services.AddNeverBounce("secret_your_api_key_here");
// Option 2: From configuration
builder.Services.AddNeverBounce(builder.Configuration);
// Option 3: With custom options
builder.Services.AddNeverBounce(options =>
{
options.ApiKey = "secret_your_api_key_here";
options.TimeoutSeconds = 30;
options.ThrowOnError = false;
});// appsettings.json
{
"NeverBounce": {
"ApiKey": "secret_your_api_key_here",
"TimeoutSeconds": 30
}
}public class EmailService
{
private readonly INeverBounceClient _neverBounce;
public EmailService(INeverBounceClient neverBounce)
{
_neverBounce = neverBounce;
}
public async Task SendEmailAsync(string email, string message)
{
// Validate before sending
var result = await _neverBounce.ValidateAsync(email);
if (!result.IsSafeToSend)
{
throw new InvalidOperationException(
$"Cannot send to {email}: {result.Status}");
}
// Check for typo suggestions
if (!string.IsNullOrEmpty(result.SuggestedCorrection))
{
// Maybe prompt user: "Did you mean {result.SuggestedCorrection}?"
}
// Proceed with sending...
}
}| Status | IsSafeToSend |
Description |
|---|---|---|
Valid |
✅ Yes | Verified real address that can receive emails |
Invalid |
❌ No | Verified as not valid - will hard bounce |
Disposable |
❌ No | Temporary/disposable address - high bounce risk |
Catchall |
✅ Yes | Domain accepts all emails (unverifiable) |
Unknown |
❌ No | Server cannot be reached - status unknown |
Error |
❌ No | Validation service error or timeout |
var result = await client.ValidateAsync("test@example.com");
// Core properties
result.Email // The email that was validated
result.Status // EmailValidationStatus enum
result.IsSafeToSend // true for Valid or Catchall
// Flags
result.IsDisposable // Temporary email service
result.IsRoleAccount // info@, support@, etc.
result.IsFreeEmail // Gmail, Yahoo, etc.
result.HasBadSyntax // Invalid email format
result.HasDns // Domain has DNS records
result.HasMxRecords // Domain has MX records
result.Flags // Raw list of all flags
// Additional info
result.SuggestedCorrection // Typo fix suggestion
result.ExecutionTimeMs // API response time
result.RawResponse // Raw JSON (if enabled)services.AddNeverBounce(options =>
{
// Required: Your NeverBounce API key
options.ApiKey = "secret_xxx";
// API base URL (default: production API)
options.BaseUrl = "https://api.neverbounce.com/v4.2";
// Request timeout in seconds (default: 30)
options.TimeoutSeconds = 30;
// Throw exception on API errors instead of returning Error status
options.ThrowOnError = false;
// Include raw JSON response in results for debugging
options.IncludeRawResponse = false;
});Check your credit balance:
var info = await client.GetAccountInfoAsync();
Console.WriteLine($"Free credits remaining: {info.FreeCreditsRemaining}");
Console.WriteLine($"Paid credits remaining: {info.PaidCreditsRemaining}");var result = await client.ValidateAsync(email);
if (result.Status == EmailValidationStatus.Error)
{
// API error occurred - handle gracefully
// You might want to allow the email through or retry
}try
{
var result = await client.ValidateAsync(email);
}
catch (NeverBounceException ex)
{
Console.WriteLine($"API Error: {ex.Message}");
Console.WriteLine($"Status Code: {ex.StatusCode}");
}- Validate at entry point - Validate emails when users enter them, not just before sending
- Handle catchall carefully - These emails may or may not exist
- Log suggestions - Track typo corrections for UX improvements
- Monitor credits - Set up alerts when credits run low
- Cache results - Consider caching validation results to reduce API calls
MIT License - see LICENSE file for details.