email

package
v0.0.7 Latest Latest
Warning

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

Go to latest
Published: Jul 22, 2026 License: Apache-2.0 Imports: 13 Imported by: 1

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func EmailCheck

func EmailCheck() string

func FormatMailReport

func FormatMailReport(report MailReport) string

FormatMailReport renders the structured result in the compact table used by the standalone command. JSON callers should encode MailReport directly.

Types

type Dialer

type Dialer interface {
	DialContext(ctx context.Context, network, address string) (net.Conn, error)
}

Dialer is the minimal transport dependency needed by CheckMail.

type EndpointKind

type EndpointKind string

EndpointKind identifies the distinct mail capabilities reported by the checker. In particular, local listen and outbound SMTP are separate tests.

const (
	KindLocalListen    EndpointKind = "local_listen"
	KindOutboundSMTP25 EndpointKind = "outbound_smtp25"
	KindMXSMTP25       EndpointKind = "mx_smtp25"
	KindFixedProtocol  EndpointKind = "fixed_protocol"
)

type EndpointResult

type EndpointResult struct {
	Kind       EndpointKind `json:"kind"`
	Platform   string       `json:"platform,omitempty"`
	Host       string       `json:"host,omitempty"`
	Domain     string       `json:"domain,omitempty"`
	Protocol   string       `json:"protocol,omitempty"`
	Port       int          `json:"port"`
	TLS        bool         `json:"tls"`
	Preference uint16       `json:"mx_preference,omitempty"`
	Status     MailStatus   `json:"status"`
	Evidence   string       `json:"evidence,omitempty"`
	Error      string       `json:"error,omitempty"`
	LatencyMS  int64        `json:"latency_ms"`
}

type LocalListener

type LocalListener interface {
	Listen(network, address string) (net.Listener, error)
}

LocalListener is retained for source compatibility with the first structured API. CheckMail no longer binds ports to infer listener state; local listeners are detected by loopback connections through Dialer.

type MXResolver

type MXResolver interface {
	LookupMX(ctx context.Context, domain string) ([]*net.MX, error)
}

MXResolver is injectable for offline and deterministic tests.

type MailReport

type MailReport struct {
	SchemaVersion  string           `json:"schema_version"`
	Local          []EndpointResult `json:"local"`
	OutboundSMTP25 []EndpointResult `json:"outbound_smtp25"`
	MX             []EndpointResult `json:"mx"`
	Fixed          []EndpointResult `json:"fixed"`
	GeneratedAt    time.Time        `json:"generated_at"`
}

func CheckMail

func CheckMail(ctx context.Context, specs []PlatformSpec, mx MXResolver, dialer Dialer, _ LocalListener) MailReport

CheckMail runs local, outbound, dynamic-MX, and fixed endpoint checks.

type MailStatus

type MailStatus string
const (
	MailAvailable   MailStatus = "available"
	MailUnavailable MailStatus = "unavailable"
	MailTimeout     MailStatus = "timeout"
	MailRefused     MailStatus = "refused"
	MailError       MailStatus = "error"
	MailUnsupported MailStatus = "unsupported"
)

type PlatformSpec

type PlatformSpec struct {
	Name     string
	Domain   string
	SMTPHost string
	POP3Host string
	IMAPHost string
}

PlatformSpec is a provider's fixed endpoints and its domain for MX lookup.

func DefaultPlatformSpecs

func DefaultPlatformSpecs() []PlatformSpec

DefaultPlatformSpecs converts the existing model maps into structured specs.

type Result

type Result struct {
	Platform string
	Status   string
}

Jump to

Keyboard shortcuts

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