Krugertech.Net.RfcEmailValidator 1.0.0

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

RFC Compliant Email Address Validator

A lightweight email address validator that implements full support for RFC5322 and partial support for RFC6531 & RFC2822 without dependencies on System.Net.Mail.

Overview

This EmailValidator class provides comprehensive email validation covering the most common use cases while maintaining good performance and avoiding the bulk of System.Net.Mail dependencies.

Current RFC Coverage

✅ RFC 5322 (Basic Email Format) - Fully Supported

  • ✅ Basic local-part@domain structure
  • ✅ Dot-atom format in local parts (user.name@domain.com)
  • ✅ Quoted strings in local parts ("john smith"@domain.com)
  • ✅ Domain validation with proper TLD requirements (minimum 2 characters)
  • ✅ IP literals for domains [192.168.1.1]
  • ✅ Length restrictions (local part <64 chars, domain <253 chars, total ❤️20 chars)
  • ✅ Special characters in local parts (!#$%&'*+-/=?^_`{|}~)
  • ✅ Comments handling (strips comments in parentheses)
  • ✅ Display name parsing with angle brackets
  • ✅ Proper whitespace validation (rejects leading/trailing spaces)
  • ✅ Domain label count limits (max 10 levels)

✅ RFC 2822 Support - Partially Supported

  • ✅ Basic address parsing
  • ✅ Display name parsing with angle brackets ("Name" email@domain.com)
  • ✅ Some folding whitespace handling
  • ✅ Basic comment parsing and removal

✅ RFC 6531 (Internationalization) - Partially Supported

  • ✅ International characters in local parts (éléonore@example.com)
  • ✅ International domain names (user@münchen.de)
  • ✅ Unicode character support in domains and local parts

Missing/Incomplete Areas

❌ RFC 5322 Gaps

  1. Obsolete syntax support - RFC 5322 requires backward compatibility with some obsolete formats
  2. Complete folding whitespace (FWS) handling - Limited support for complex whitespace folding
  3. Proper CFWS (comments/folding whitespace) parsing - Basic comment removal, not full CFWS parsing
  4. Advanced domain literal validation - IPv6 validation is simplified, needs full RFC compliance
  5. Complete quoted-pair handling - Limited escape sequence support in quoted strings
  6. Nested comment parsing - Comments within comments not fully supported

❌ RFC 6531 Gaps

  1. SMTPUTF8 extension considerations - No specific SMTP UTF-8 extension handling
  2. Complete UTF-8 validation and normalization - No Unicode normalization (NFC/NFD)
  3. International domain name (IDN) encoding/decoding - No Punycode conversion
  4. EAI (Email Address Internationalization) edge cases - Some complex internationalization scenarios

❌ RFC 2822 Legacy Support

  1. Route addressing - Obsolete <@route:user@domain> format not supported
  2. Group syntax - Group: user1@domain1, user2@domain2; format not supported
  3. Complete obsolete format support - Various legacy formats from RFC 2822

API Usage

Basic Validation

using KrugerTech.Net;

bool isValid = EmailValidator.IsRfcCompliant("user@example.com");

Email Parsing

using KrugerTech.Net;

EmailAddress? parsed = EmailValidator.ParseEmail("\"John Doe\" <john.doe@example.com>");
if (parsed != null)
{
    Console.WriteLine($"Display Name: {parsed.DisplayName}");
    Console.WriteLine($"Local Part: {parsed.LocalPart}");
    Console.WriteLine($"Domain: {parsed.Domain}");
    Console.WriteLine($"Full Address: {parsed.Address}");
}

Typical Usage Scenarios

  • Validate user input:

    if (EmailValidator.IsRfcCompliant(userInput)) {
            // Accept email
    } else {
            // Show validation error
    }
    
  • Extract components for storage or display:

    var email = EmailValidator.ParseEmail(input);
    if (email != null) {
            SaveToDatabase(email.LocalPart, email.Domain);
    }
    
Product Compatible and additional computed target framework versions.
.NET net6.0 is compatible.  net6.0-android was computed.  net6.0-ios was computed.  net6.0-maccatalyst was computed.  net6.0-macos was computed.  net6.0-tvos was computed.  net6.0-windows was computed.  net7.0 was computed.  net7.0-android was computed.  net7.0-ios was computed.  net7.0-maccatalyst was computed.  net7.0-macos was computed.  net7.0-tvos was computed.  net7.0-windows was computed.  net8.0 was computed.  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.
  • net6.0

    • No dependencies.

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 330 8/25/2025

Initial release