spf

package
v0.54.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Apr 4, 2024 License: BSD-3-Clause Imports: 11 Imported by: 0

Documentation

Overview

Package spf implement Sender Policy Framework (SPF) per RFC 7208.

Index

Constants

View Source
const (
	// A "pass" result is an explicit statement that the client is
	// authorized to inject mail with the given identity.
	ResultCodePass byte = iota

	// A result of "none" means either,
	// (a) no syntactically valid DNS domain name was extracted from the
	//     SMTP session that could be used as the one to be authorized, or
	// (b) no SPF records were retrieved from the DNS.
	ResultCodeNone

	// A "neutral" result means the ADMD has explicitly stated that it is
	// not asserting whether the IP address is authorized.
	ResultCodeNeutral

	// A "fail" result is an explicit statement that the client is not
	// authorized to use the domain in the given identity.
	ResultCodeFail

	// A "softfail" result is a weak statement by the publishing ADMD that
	// the host is probably not authorized.
	// It has not published a stronger, more definitive policy that
	// results in a "fail".
	ResultCodeSoftfail

	// A "temperror" result means the SPF verifier encountered a transient
	// (generally DNS) error while performing the check.
	// A later retry may // succeed without further DNS operator action.
	ResultCodeTempError

	// A "permerror" result means the domain’s published records could not
	// be correctly interpreted.
	// This signals an error condition that definitely requires DNS
	// operator intervention to be resolved.
	ResultCodePermError
)

List of possible result code as described in RFC 7208 section 2.6.

Variables

This section is empty.

Functions

This section is empty.

Types

type Result

type Result struct {
	IP net.IP // The IP address of sender.

	Err string

	Domain   []byte // The domain address of sender from SMTP EHLO or MAIL FROM command.
	Sender   []byte // The email address of sender.
	Hostname []byte

	Code byte // Result of check host.
	// contains filtered or unexported fields
}

Result contains the output of CheckHost function.

func CheckHost

func CheckHost(ip net.IP, domain, sender, hostname string) (result *Result)

CheckHost fetches SPF records, parses them, and evaluates them to determine whether a particular host is or is not permitted to send mail with a given identity.

func (*Result) Error

func (result *Result) Error() string

Error return the string representation of the result as error message.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL