RFC 5321/5322 compliant email validation with typo suggestions, disposable email detection, and bulk validation.
dotnet add package Philiprehberger.EmailValidatorRFC 5321/5322 compliant email validation with typo suggestions, disposable email detection, and bulk validation.
dotnet add package Philiprehberger.EmailValidator
using Philiprehberger.EmailValidator;
bool valid = EmailValidator.IsValid("user@example.com");
// true
bool invalid = EmailValidator.IsValid("not-an-email");
// false
using Philiprehberger.EmailValidator;
var result = EmailValidator.Validate("user@example.com");
// result.IsValid → true
// result.Error → null
// result.NormalizedAddress → "user@example.com"
var failed = EmailValidator.Validate("user@.com");
// failed.IsValid → false
// failed.Error → "Domain must not contain empty labels."
using Philiprehberger.EmailValidator;
var result = EmailValidator.Validate("user@münchen.de");
// result.IsValid → true
// result.NormalizedAddress → "user@xn--mnchen-3ya.de"
using Philiprehberger.EmailValidator;
var result = EmailValidator.ValidateWithSuggestion("user@gmial.com");
// result.IsValid → true
// result.Suggestion → "user@gmail.com"
using Philiprehberger.EmailValidator;
bool disposable = EmailValidator.IsDisposable("user@mailinator.com");
// true
bool legit = EmailValidator.IsDisposable("user@gmail.com");
// false
using Philiprehberger.EmailValidator;
var results = EmailValidator.ValidateMany(new[] { "a@b.com", "invalid", "c@d.org" });
// results[0].IsValid → true
// results[1].IsValid → false
// results[2].IsValid → true
| Member | Returns | Description |
|---|---|---|
EmailValidator.IsValid(string email) | bool | Returns whether the email address is valid. |
EmailValidator.Validate(string email) | ValidationResult | Returns a detailed validation result with error and normalized address. |
ValidationResult.IsValid | bool | Whether the email address is valid. |
ValidationResult.Error | string? | Error message if invalid, null if valid. |
ValidationResult.NormalizedAddress | string? | Lowercased, trimmed email if valid, null if invalid. |
ValidationResult.Suggestion | string? | Suggested corrected email if a domain typo was detected, null otherwise. |
ValidationResult.IsDisposable | bool | Whether the email domain belongs to a known disposable email provider. |
EmailValidator.ValidateWithSuggestion(string email) | ValidationResult | Validates and suggests a correction if the domain is a typo of a common provider. |
EmailValidator.ValidateMany(IEnumerable<string> emails) | IReadOnlyList<ValidationResult> | Validates multiple email addresses and returns results in order. |
EmailValidator.IsDisposable(string email) | bool | Checks whether the email domain is a known disposable provider. |
dotnet build src/Philiprehberger.EmailValidator.csproj --configuration Release
If you find this project useful: