Documentation ¶
Overview ¶
Package spf can parse an SPF record and determine if a given IP address is allowed to send email based on that record. SPF can handle all of the mechanisms defined at http://www.openspf.org/SPF_Record_Syntax. The redirect mechanism is ignored.
Index ¶
Constants ¶
const (
MaxCount = 10
)
Variables ¶
var ( ErrNoRecord = errors.New("No SPF Record found.") ErrFailedLookup = errors.New("DNS Lookup failed.") ErrInvalidSPF = errors.New("Invalid SPF string.") ErrIncludeLoop = errors.New("Include loop detected.") ErrInvalidMechanism = errors.New("Invalid mechanism in SPF string.") ErrMaxCount = errors.New("Exceeded maximum lookups.") )
var (
ErrNoMatch = errors.New("Client was not covered by the mechanism.")
)
Functions ¶
Types ¶
type Mechanism ¶
Mechanism represents a single mechanism in an SPF record.
func NewMechanism ¶
NewMechanism creates a new Mechanism struct using the given string and domain name. When the mechanism does not define the domain, the provided domain is used as the default.
func (*Mechanism) Evaluate ¶
Evaluate determines if the given IP address is covered by the mechanism. If the IP is covered, the mechanism result is returned and error is nil. If the IP is not covered an error is returned. The caller must check for the error to determine if the result is valid.
type SPF ¶
SPF represents an SPF record for a particular Domain. The SPF record holds all of the Allow, Deny, and Neutral mechanisms.
func NewSPF ¶
Create a new SPF record for the given domain using the provided string. If the provided string is not valid an error is returned.
func (*SPF) SPFString ¶
SPFString returns a formatted SPF object as a string suitable for use in a TXT record.