verify

package
v1.1.0 Latest Latest
Warning

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

Go to latest
Published: Nov 4, 2026 License: MIT Imports: 5 Imported by: 0

Documentation

Overview

Package verify checks whether an email address is likely to be deliverable. The PreSignUp hook passes the result to its policy as input.emailVerification.

Index

Constants

View Source
const (
	ProviderSendGrid  = "sendgrid"
	ProviderAllowlist = "allowlist"
)

Provider names, reported in Result.Provider.

View Source
const (
	VerdictValid   = sendgrid.VerdictValid
	VerdictRisky   = sendgrid.VerdictRisky
	VerdictInvalid = sendgrid.VerdictInvalid
)

Verdicts. They match the SendGrid validation verdicts.

Variables

This section is empty.

Functions

func Domain

func Domain(email string) (string, bool)

Domain returns the domain of a syntactically valid address.

Types

type Allowlist

type Allowlist struct {
	// Domains are matched exactly and case-insensitively; subdomains must be
	// listed separately.
	Domains []string
	Next    Verifier
}

Allowlist treats addresses in the listed domains as valid without calling Next.

func (Allowlist) Verify

func (v Allowlist) Verify(ctx context.Context, email string) (*Result, error)

type Result

type Result struct {
	// Provider is the verifier that produced the result.
	Provider string `json:"provider"`
	// Valid is false only when the address is known to be undeliverable.
	// Risky addresses are valid.
	Valid   bool   `json:"valid"`
	Verdict string `json:"verdict"`
	// Score is the likelihood that the address is deliverable, from 0 to 1.
	Score float64 `json:"score"`
	// Disposable is true when the domain belongs to a disposable email
	// service.
	Disposable bool `json:"disposable"`
	// Role is true when the local part is a role or group address, such as
	// admin@.
	Role bool `json:"role"`
	// Raw is the provider's raw response as a JSON string ("{}" when there is
	// none).
	Raw string `json:"raw"`
}

Result is the outcome of verifying one address.

type SendGrid

type SendGrid struct {
	Client *sendgrid.Client
}

SendGrid verifies addresses with the SendGrid Email Address Validation API, which needs an Email API Pro or Premier plan.

func (SendGrid) Verify

func (v SendGrid) Verify(ctx context.Context, email string) (*Result, error)

type Verifier

type Verifier interface {
	Verify(ctx context.Context, email string) (*Result, error)
}

Verifier verifies one email address. An error means the address could not be checked, not that it is invalid.

Jump to

Keyboard shortcuts

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