Table of Contents

Struct SenderDomain

Namespace
MailFathom.Domain.Emails.Authentication
Assembly
MailFathom.Domain.dll

Names the domain half of a mail identity, in the one form everything about a sender compares on.

public readonly record struct SenderDomain : IEquatable<SenderDomain>
Implements
Inherited Members

Remarks

A sending domain arrives from four unrelated places — a DKIM signature's d= tag, an SPF check's envelope sender, the From header a client displays, and an entry an operator wrote on a trusted-sender list — and the whole point of a verdict is that those can be held against each other. A comparison form derived at each of those call sites would drift between them, so the normalization is the type's own rule and NormalizedValue is the only form anything compares.

The form is upper-cased for the reason NormalizedAddress is: upper case round-trips in every culture, so the key means the same thing in memory, in a query, and in a database whose collation MailFathom does not control.

It is also the ASCII form of an internationalized name. The same domain reaches this type written both ways — a header carries the A-labels a transport agreed on while an operator types the name their language spells — and comparing the two encodings against each other would answer no on names that are the same name. Everything is therefore held in A-labels, which is the encoding the wire already uses, so an ASCII value is its own normal form and costs no conversion at all.

A domain name is personal data once it is attached to a message, so nothing here may be logged.

Fields

MaximumLength

The greatest length a domain name has, which RFC 1035 fixes at 253 characters.

Properties

NormalizedValue

Gets the comparison form of Value.

Value

Gets the domain exactly as its source wrote it, trimmed of surrounding whitespace.

Methods

Equals(SenderDomain)

Compares two domains by the form they were normalized to.

GetHashCode()

Returns the hash code for this instance.

IsSubdomainOf(SenderDomain)

Answers whether this domain lies beneath another one in the naming tree.

ToString()

Returns the fully qualified type name of this instance.

TryCreate(string?, out SenderDomain)

Builds a domain from what a header wrote.

TryCreateFromMailbox(string?, out SenderDomain)

Builds a domain from a mailbox, which is what an SPF check and a From header both carry.