types

package
v2.0.1 Latest Latest
Warning

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

Go to latest
Published: Oct 4, 2025 License: MIT Imports: 6 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Address

type Address struct {
	Name string
	Mail string
}

Address represents a single email address with an optional display name.

func MustAddr

func MustAddr(s string) Address

MustAddr parses an address like "Ada <ada@example.com>" or "ada@example.com". Panics on error. Use in examples or tests.

Parameters:

  • s: The address string to parse.

Returns:

  • Address: The parsed address.

func ParseAddress

func ParseAddress(s string) (Address, error)

ParseAddress parses a single address string into Address.

Parameters:

  • s: The address string to parse.

Returns:

  • Address: The parsed address.
  • error: An error if the address string is invalid.

func ParseAddressList

func ParseAddressList(list []string) ([]Address, error)

ParseAddressList parses a header-like list into []Address.

Parameters:

  • list: The list of address strings to parse.

Returns:

  • []Address: The parsed addresses.
  • error: An error if the address list is invalid.

func (Address) String

func (a Address) String() string

String renders a display-friendly representation for headers.

Returns:

  • string: The display-friendly representation of the address.

type Attachment

type Attachment struct {
	Filename    string    // file name to present in email client
	ContentType string    // e.g. "application/pdf"
	ContentID   string    // set to serve as inline image "cid:<ContentID>"
	Reader      io.Reader // streamed content
}

Attachment represents a file attachment or inline image.

type DKIMConfig

type DKIMConfig struct {
	Domain   string
	Selector string
	KeyPEM   []byte
	Headers  []string
}

DKIMConfig enables DKIM signing (rsa-sha256, relaxed/relaxed). Headers lists which header field names to include in "h=" in order. Use lowercase names (e.g. "from", "to", "subject").

type Hooks

type Hooks struct {
	OnBuildStart func(ctx context.Context, msg *Message) context.Context
	OnBuildDone  func(ctx context.Context, msg *Message, size int,
		err error)
	OnAttemptStart func(ctx context.Context, attempt int) context.Context
	OnAttemptDone  func(ctx context.Context, attempt int, err error)
}

Hooks allows you to integrate tracing/metrics without extra deps. Return a derived context from Start hooks if you want to carry spans.

type Message

type Message struct {
	From       Address
	To         []Address
	Cc         []Address
	Bcc        []Address
	Subject    string
	Plain      []byte // optional
	HTML       []byte // optional
	Attach     []Attachment
	Headers    map[string]string
	TrackingID string
}

Message is the high-level representation of an email.

func (*Message) CloneHeaders

func (m *Message) CloneHeaders() map[string]string

CloneHeaders returns a shallow copy safe for per-send mutation.

func (*Message) RecipientList

func (m *Message) RecipientList() []string

RecipientList returns combined To+Cc+Bcc for envelope use.

func (*Message) Validate

func (m *Message) Validate() error

Validate minimal correctness before send.

Returns:

  • error: An error if the message is invalid.

Jump to

Keyboard shortcuts

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