Domain Detective

API Reference

Class

SpfAnalysis

Namespace DomainDetective
Assembly DomainDetective
Implements

To validate an SPF record according to the RFC 7208 standard, you would need to check for several things.Here are some of the key points: 1. The SPF record must start with "v=spf1". 2. The SPF record should not exceed 10 DNS lookups - SPF implementations MUST limit the number of mechanisms and modifiers that do DNS lookups to at most 10 per SPF check, including any lookups caused by the use of the "include" mechanism or the "redirect" modifier. If this number is exceeded during a check, a PermError MUST be returned. The "include", "a", "mx", "ptr", and "exists" mechanisms as well as the "redirect" modifier do count against this limit. The "all", "ip4", and "ip6" mechanisms do not require DNS lookups and therefore do not count against this limit. The "exp" modifier does not count against this limit because the DNS lookup to fetch the explanation string occurs after the SPF record has been evaluated. 3. The SPF record should not have more than one "all" mechanism. 4. The total length of the SPF record should stay below 512 bytes when possible. 5. Each TXT chunk of the SPF record must be 255 bytes or less.

Inheritance

  • Object
  • SpfAnalysis

Usage

This type appears in these public API surfaces even when no hand-authored example is attached directly to the page.

Returned or exposed by

Accepted by parameters

Constructors

Methods

public async Task AnalyzeSpfRecords(IEnumerable<DnsAnswer> dnsResults, InternalLogger logger) #
Returns: Task

Analyzes spf records.

Parameters

dnsResults System.Collections.Generic.IEnumerable{DnsClientX.DnsAnswer} requiredposition: 0
logger DomainDetective.InternalLogger requiredposition: 1
public async Task ComputeEffectiveSpfSendsAsync(InternalLogger logger = null) #
Returns: Task

Computes whether SPF effectively authorizes outbound sending after resolving include/redirect chains and updates EffectiveSpfSends.

Parameters

logger DomainDetective.InternalLogger = null optionalposition: 0
public async Task<SpfHostEvaluation> EvaluateHostAsync(String domain, IPAddress ip, String sender, String helo, InternalLogger logger = null) #
Returns: Task<SpfHostEvaluation>

Evaluates the SPF policy for the specified domain against an IP/sender/HELO.

Parameters

domain System.String requiredposition: 0
Domain whose SPF policy is evaluated.
ip System.Net.IPAddress requiredposition: 1
IP address to test.
sender System.String requiredposition: 2
RFC 5322 Sender used in macro expansion; defaults to postmaster@domain.
helo System.String requiredposition: 3
HELO/EHLO name used in macro expansion; defaults to mail.domain.
logger DomainDetective.InternalLogger = null optionalposition: 4
Optional logger for diagnostics.

Returns

Evaluation result with verdict, matched token, source and lookup statistics.

public async Task<String> GetExplanationText(IPAddress ip, String sender, String helo, String domain, InternalLogger logger = null) #
Returns: Task<String>

Gets explanation text.

Parameters

ip System.Net.IPAddress requiredposition: 0
sender System.String requiredposition: 1
helo System.String requiredposition: 2
domain System.String requiredposition: 3
logger DomainDetective.InternalLogger = null optionalposition: 4
public async Task<List<String>> GetFlattenedIpAddresses(String domainName, InternalLogger logger = null) #
Returns: Task<List<String>>

Returns all IP addresses referenced by the SPF record after resolving includes and redirects.

Parameters

domainName System.String requiredposition: 0
Base domain used when an a or mx mechanism omits a domain.
logger DomainDetective.InternalLogger = null optionalposition: 1
Optional logger for diagnostics.
public async Task<FlattenedSpfResult> GetFlattenedIpAnalysis(String domainName, InternalLogger logger = null) #
Returns: Task<FlattenedSpfResult>

Generates a detailed analysis of flattened SPF IP addresses.

Parameters

domainName System.String requiredposition: 0
Base domain used when an a or mx mechanism omits a domain.
logger DomainDetective.InternalLogger = null optionalposition: 1
Optional logger for diagnostics.
public async Task<String> GetFlattenedSpf(InternalLogger logger = null) #
Returns: Task<String>

Gets flattened spf.

Parameters

logger DomainDetective.InternalLogger = null optionalposition: 0
public async Task<List<String>> GetFlattenedSpfTree(InternalLogger logger = null) #
Returns: Task<List<String>>

Builds a flattened SPF tree representation with indentation showing include and redirect branches.

Parameters

logger DomainDetective.InternalLogger = null optionalposition: 0
public async Task PopulateProvenanceAsync(String domain, InternalLogger logger = null) #
Returns: Task

Populates SpfPartAnalyses with provenance by traversing include/redirect chains.

Parameters

domain System.String requiredposition: 0
Base domain whose SPF record is being analyzed.
logger DomainDetective.InternalLogger = null optionalposition: 1
Optional logger for diagnostics.
public Void Reset() #
Returns: Void

Executes the reset operation.

ValidateMacros(System.String token, DomainDetective.InternalLogger logger) #

Validates SPF macro syntax within a token and records warnings.

Parameters

token System.String required
SPF token that may contain macros.
logger DomainDetective.InternalLogger required
Optional logger for diagnostics.
WarnIfSpfRecordChunksTooLong(DomainDetective.InternalLogger arg1) #

Adds warnings for SPF TXT chunks over 255 characters.

Parameters

arg1 DomainDetective.InternalLogger required

Properties

public String Subject { get; set; } #

Gets or sets the subject value.

public Nullable<Int32> DnsRecordTtl { get; set; } #

DNS TTL (seconds) of the SPF TXT record as returned by DNS.

public Nullable<Int32> CnameTtl { get; set; } #

TTL (seconds) of the CNAME record when this record was resolved via CNAME alias.

public Boolean IsCnameResolved { get; set; } #

True when the SPF record was resolved through a CNAME alias.

public String SpfRecord { get; set; } #

Combined SPF record text.

public List<String> SpfRecords { get; set; } #

Gets or sets the spf records value.

public Boolean SpfRecordExists { get; set; } #

Gets or sets the spf record exists value.

public Boolean MultipleSpfRecords { get; set; } #

Gets or sets the multiple spf records value.

public Boolean StartsCorrectly { get; set; } #

Gets or sets the starts correctly value.

public Boolean ExceedsTotalCharacterLimit { get; set; } #

Gets or sets the exceeds total character limit value.

public Boolean ExceedsCharacterLimit { get; set; } #

Gets or sets the exceeds character limit value.

public List<String> DnsLookups { get; set; } #

Gets or sets the dns lookups value.

public Int32 DnsLookupsCount { get; set; } #

Gets or sets the dns lookups count value.

public Boolean ExceedsDnsLookups { get; set; } #

Gets or sets the exceeds dns lookups value.

public Boolean MultipleAllMechanisms { get; set; } #

Gets or sets the multiple all mechanisms value.

public Boolean ContainsCharactersAfterAll { get; set; } #

Gets or sets the contains characters after all value.

public Boolean HasPtrType { get; set; } #

Gets or sets the has ptr type value.

public Boolean HasNullLookups { get; set; } #

Gets or sets the has null lookups value.

public Boolean HasRedirect { get; set; } #

Gets or sets the has redirect value.

public Boolean HasExp { get; set; } #

Gets or sets the has exp value.

public Boolean InvalidIpSyntax { get; set; } #

Gets or sets the invalid ip syntax value.

public Boolean DenyAll { get; set; } #

True when the SPF policy appears to deny all sending (e.g., v=spf1 -all with no allow mechanisms).

public List<String> ARecords { get; set; } #

Gets or sets the a records value.

public List<String> Ipv4Records { get; set; } #

Gets or sets the ipv4 records value.

public List<String> Ipv6Records { get; set; } #

Gets or sets the ipv6 records value.

public List<String> MxRecords { get; set; } #

Gets or sets the mx records value.

public List<String> PtrRecords { get; set; } #

Gets or sets the ptr records value.

public List<String> IncludeRecords { get; set; } #

Gets or sets the include records value.

public List<String> ExistsRecords { get; set; } #

Gets or sets the exists records value.

public String ExpValue { get; set; } #

Gets or sets the exp value value.

public String RedirectValue { get; set; } #

Gets or sets the redirect value value.

public String AllMechanism { get; set; } #

Gets or sets the all mechanism value.

public List<String> ResolvedARecords { get; set; } #

Gets or sets the resolved a records value.

public List<String> ResolvedIpv4Records { get; set; } #

Gets or sets the resolved ipv4 records value.

public List<String> ResolvedIpv6Records { get; set; } #

Gets or sets the resolved ipv6 records value.

public List<String> ResolvedMxRecords { get; set; } #

Gets or sets the resolved mx records value.

public List<String> ResolvedPtrRecords { get; set; } #

Gets or sets the resolved ptr records value.

public List<String> ResolvedIncludeRecords { get; set; } #

Gets or sets the resolved include records value.

public List<String> ResolvedExistsRecords { get; set; } #

Gets or sets the resolved exists records value.

public List<String> UnknownMechanisms { get; set; } #

Gets or sets the unknown mechanisms value.

public FlattenedSpfResult FlattenedIpAnalysis { get; set; } #

Gets or sets the flattened ip analysis value.

public Dictionary<String, String> TestSpfRecords { get; } #

Gets the test spf records value.

public Boolean CycleDetected { get; set; } #

Gets or sets the cycle detected value.

public String CyclePath { get; set; } #

Gets or sets the cycle path value.

public Boolean PermError { get; set; } #

Gets or sets the perm error value.

public List<String> RedirectVisitedDomains { get; set; } #

Gets or sets the redirect visited domains value.

public String Advisory { get; set; } #

Summary message describing overall SPF status.

public List<SpfPartAnalysis> SpfPartAnalyses { get; set; } #

Gets or sets the spf part analyses value.

public List<SpfTestResult> SpfTestResults { get; set; } #

Gets or sets the spf test results value.

public Func<String, DnsRecordType, Task<DnsAnswer[]>> QueryDnsOverride { get; set; } #

Represents the query dns override value.

public Int32 ExpDnsLookupsCount { get; set; } #

Gets or sets the exp dns lookups count value.

public Boolean ExpExceedsDnsLookups { get; set; } #

Gets or sets the exp exceeds dns lookups value.

public IReadOnlyList<String> Warnings { get; } #

Represents the warnings value.

public IReadOnlyList<String> DebugTokens { get; set; } #

Gets or sets the debug tokens value.

public String DebugAllAfterParts { get; set; } #

Gets or sets the debug all after parts value.

public String DebugAllAfterFallback { get; set; } #

Gets or sets the debug all after fallback value.

public virtual List<Assessment> Assessments { get; } #

Structured assessments captured during SPF analysis.

public IReadOnlyList<RecommendationAdvice> Recommendations { get; } #

Actionable recommendations derived from assessments.

public Boolean EffectiveSpfSends { get; set; } #

True when SPF configuration effectively authorizes outbound senders after resolving include/redirect chains as per RFC 7208.

public IReadOnlyList<StandardReference> RfcReferences { get; } #

Relevant standards for SPF analysis.

{{ include "footer" }}