smtp

package
v1.26.0 Latest Latest
Warning

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

Go to latest
Published: Oct 12, 2026 License: MIT Imports: 21 Imported by: 0

Documentation

Index

Constants

View Source
const (
	StartTLSOff      = "off"
	StartTLSAuto     = "auto"
	StartTLSRequired = "required"
)

The values of starttls.

Variables

This section is empty.

Functions

func OptimisticUID

func OptimisticUID() (string, error)

func Params

func Params() []string

Params returns the keys the smtp action takes in with.

func Send

func Send(data map[string]any, opts ...Option) (map[string]any, error)

func Serve

func Serve()

Types

type Action

type Action struct {
	// contains filtered or unexported fields
}

func (*Action) Run

func (a *Action) Run(with map[string]any) (map[string]any, error)

type Bulk

type Bulk struct {
	Addr       string `map:"addr" validate:"required"`
	From       string `map:"from" validate:"required"`
	To         string `map:"to" validate:"required"`
	Subject    string `map:"subject"`
	MyHostname string `map:"myhostname"`
	Session    int    `map:"session"`
	Message    int    `map:"message"`
	Length     int    `map:"length"`

	// StartTLS is off, auto or required, as the smtp action's starttls. It
	// is off when empty, as Bulk always was.
	StartTLS string
	// InsecureSkipTLS accepts any certificate after STARTTLS.
	InsecureSkipTLS bool
	// contains filtered or unexported fields
}

func NewBulk

func NewBulk(p map[string]any) (*Bulk, error)

func (*Bulk) Deliver

func (b *Bulk) Deliver()

func (*Bulk) DeliverWithResult

func (b *Bulk) DeliverWithResult() DeliveryResult

func (*Bulk) MakeData

func (b *Bulk) MakeData() []byte

MakeData returns the mail data for external access

func (*Bulk) Send

func (b *Bulk) Send() (int, error)

type Callback

type Callback struct {
	// contains filtered or unexported fields
}

type Client

type Client struct {
	Text *textproto.Conn
	// contains filtered or unexported fields
}

func Dial

func Dial(addr string) (*Client, error)

func NewClient

func NewClient(conn net.Conn, host string) (*Client, error)

func (*Client) Auth

func (c *Client) Auth(a smtp.Auth) error

func (*Client) Close

func (c *Client) Close() error

func (*Client) Data

func (c *Client) Data() (io.WriteCloser, error)

func (*Client) Extension

func (c *Client) Extension(ext string) (bool, string)

func (*Client) Hello

func (c *Client) Hello(localName string) error

func (*Client) Mail

func (c *Client) Mail(from string) error

func (*Client) Noop

func (c *Client) Noop() error

func (*Client) Quit

func (c *Client) Quit() error

func (*Client) Rcpt

func (c *Client) Rcpt(to string) error

func (*Client) Reset

func (c *Client) Reset() error

func (*Client) StartTLS

func (c *Client) StartTLS(config *tls.Config) error

func (*Client) TLSConnectionState

func (c *Client) TLSConnectionState() (state tls.ConnectionState, ok bool)

func (*Client) Verify

func (c *Client) Verify(addr string) error

type DeliveryResult

type DeliveryResult struct {
	Sent     int
	Failed   int
	Total    int
	Sessions int
	Error    string
	// Rejected is set when a failed session got a reply from the server,
	// such as a 550 to RCPT TO, rather than failing to reach it.
	Rejected bool
}

type Mail

type Mail struct {
	Addr string
	// LocalName is the host name sent in EHLO and HELO. When it is empty the
	// machine's host name is used, falling back to "localhost".
	LocalName        string
	MailFrom         string
	RcptTo           []string
	Data             []byte
	Auth             smtp.Auth
	StartTLSDisabled bool
	// StartTLSRequired fails the session when the server does not offer
	// STARTTLS, instead of going on in plain text.
	StartTLSRequired bool
	// InsecureSkipVerify accepts any certificate after STARTTLS, such as a
	// self-signed one.
	InsecureSkipVerify bool
	MessageCount       int
	// Delivered is how many messages the server accepted in the last Send.
	// Each message is committed on its own, so a Send that fails part way
	// has still delivered the ones before.
	Delivered int
}

func (*Mail) Send

func (m *Mail) Send() error

type MockServer

type MockServer struct {
	Addr string
	Name string
	Log  *log.Logger
	*TLS
	// contains filtered or unexported fields
}

func (*MockServer) Serve

func (s *MockServer) Serve() error

type MockServerSession

type MockServerSession struct {
	// contains filtered or unexported fields
}

type Option

type Option func(*Callback)

func WithAfter

func WithAfter(f func(result *Result)) Option

func WithBefore

func WithBefore(f func(from string, to string, subject string)) Option

type Req

type Req struct {
	Addr       string `map:"addr" validate:"required"`
	From       string `map:"from" validate:"required"`
	To         string `map:"to" validate:"required"`
	Subject    string `map:"subject"`
	MyHostname string `map:"myhostname"`
	Session    int    `map:"session"`
	Message    int    `map:"message"`
	Length     int    `map:"length"`
	// StartTLS is off, auto (use it when the server offers it) or required
	// (fail when it does not).
	StartTLS        string `map:"starttls"`
	InsecureSkipTLS bool   `map:"insecure_skip_tls"`
	// contains filtered or unexported fields
}

func NewReq

func NewReq() *Req

func (*Req) Do

func (r *Req) Do() (*Result, error)

type Res

type Res struct {
	Code     int    `map:"code"`
	Sent     int    `map:"sent"`
	Failed   int    `map:"failed"`
	Total    int    `map:"total"`
	Error    string `map:"error"`
	MailData string `map:"maildata"` // For text mail data
	FilePath string `map:"filepath"` // For binary mail data files
}

type Result

type Result struct {
	Req    Req           `map:"req"`
	Res    Res           `map:"res"`
	RT     time.Duration `map:"rt"`
	Status int           `map:"status"`
}

type TLS

type TLS struct {
	CertPath string
	KeyPath  string
}

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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