Hymma.NeverBounce 1.0.0

Prefix Reserved
dotnet add package Hymma.NeverBounce --version 1.0.0
                    
NuGet\Install-Package Hymma.NeverBounce -Version 1.0.0
                    
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="Hymma.NeverBounce" Version="1.0.0" />
                    
For projects that support PackageReference, copy this XML node into the project file to reference the package.
<PackageVersion Include="Hymma.NeverBounce" Version="1.0.0" />
                    
Directory.Packages.props
<PackageReference Include="Hymma.NeverBounce" />
                    
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 Hymma.NeverBounce --version 1.0.0
                    
#r "nuget: Hymma.NeverBounce, 1.0.0"
                    
#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 Hymma.NeverBounce@1.0.0
                    
#: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=Hymma.NeverBounce&version=1.0.0
                    
Install as a Cake Addin
#tool nuget:?package=Hymma.NeverBounce&version=1.0.0
                    
Install as a Cake Tool

Hymma.NeverBounce

⚠️ 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.

Features

  • 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

Installation

From NuGet.org

dotnet add package Hymma.NeverBounce

From Local Build

dotnet pack -c Release
dotnet add package Hymma.NeverBounce --source ./src/Hymma.NeverBounce/bin/Release

Quick Start

1. Register Services

// 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;
});

2. Add Configuration (if using Option 2)

// appsettings.json
{
  "NeverBounce": {
    "ApiKey": "secret_your_api_key_here",
    "TimeoutSeconds": 30
  }
}

3. Use the Client

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...
    }
}

Validation Statuses

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

Result Properties

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)

Configuration Options

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;
});

Account Information

Check your credit balance:

var info = await client.GetAccountInfoAsync();

Console.WriteLine($"Free credits remaining: {info.FreeCreditsRemaining}");
Console.WriteLine($"Paid credits remaining: {info.PaidCreditsRemaining}");

Error Handling

Default Behavior (ThrowOnError = false)

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
}

Strict Mode (ThrowOnError = true)

try
{
    var result = await client.ValidateAsync(email);
}
catch (NeverBounceException ex)
{
    Console.WriteLine($"API Error: {ex.Message}");
    Console.WriteLine($"Status Code: {ex.StatusCode}");
}

Best Practices

  1. Validate at entry point - Validate emails when users enter them, not just before sending
  2. Handle catchall carefully - These emails may or may not exist
  3. Log suggestions - Track typo corrections for UX improvements
  4. Monitor credits - Set up alerts when credits run low
  5. Cache results - Consider caching validation results to reduce API calls

API Reference

License

MIT License - see LICENSE file for details.

Product Compatible and additional computed target framework versions.
.NET net8.0 is compatible.  net8.0-android was computed.  net8.0-browser was computed.  net8.0-ios was computed.  net8.0-maccatalyst was computed.  net8.0-macos was computed.  net8.0-tvos was computed.  net8.0-windows was computed.  net9.0 was computed.  net9.0-android was computed.  net9.0-browser was computed.  net9.0-ios was computed.  net9.0-maccatalyst was computed.  net9.0-macos was computed.  net9.0-tvos was computed.  net9.0-windows was computed.  net10.0 was computed.  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
1.0.0 1,017 12/10/2025