smtp

package
v0.0.2 Latest Latest
Warning

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

Go to latest
Published: Oct 15, 2026 License: MIT Imports: 9 Imported by: 0

Documentation

Overview

Package smtp is the built-in mail provider: one SMTP relay per channel, a connection per delivery, 5xx replies final.

Index

Constants

View Source
const (
	TLSStartTLS = "starttls"
	TLSImplicit = "tls"
	TLSNone     = "none"
)

TLS modes.

Variables

View Source
var ErrConfig = errors.New("smtp: invalid channel")

ErrConfig is an invalid channel.

Functions

This section is empty.

Types

type Config

type Config struct {
	Host string `json:"host" schemapb:"description=Relay host"`
	Port int64  `json:"port" schemapb:"default=587;gte=1;lte=65535"`
	// TLS: starttls (default), tls (implicit on connect), none.
	TLS      string        `json:"tls"                schemapb:"default=starttls;description=starttls, tls or none"`
	Username string        `json:"username,omitempty"`
	Password config.Secret `json:"password,omitempty" schemapb:"secret=true"`
	// From is the sender when the message names none.
	From string `json:"from" schemapb:"description=Default sender, e.g. Shop <no-reply@shop.example>"`
}

Config of an SMTP channel.

func (Config) Validate

func (c Config) Validate() error

Validate checks what the schema cannot.

type Sender

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

Sender delivers through one relay.

func New

func New(cfg Config, timeout time.Duration) *Sender

New is the sender of cfg; timeout bounds one connection.

func (*Sender) Check

func (s *Sender) Check(ctx context.Context) error

Check connects and authenticates without sending.

func (*Sender) From

func (s *Sender) From() string

From is the channel's default sender.

func (*Sender) Send

func (s *Sender) Send(ctx context.Context, msg *gomail.Msg) error

Send delivers msg; a 5xx reply is a permanent *provider.Error.

Directories

Path Synopsis
Package smtptest is an SMTP server for tests: it keeps what it receives and refuses the recipients it is told to.
Package smtptest is an SMTP server for tests: it keeps what it receives and refuses the recipients it is told to.

Jump to

Keyboard shortcuts

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