smtpmail

package
v0.60.2 Latest Latest
Warning

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

Go to latest
Published: Nov 6, 2026 License: AGPL-3.0 Imports: 20 Imported by: 0

Documentation

Overview

Package smtpmail sends the mails of the API, such as login links, through an authenticated SMTP server reached over implicit TLS (RFC 8314).

Index

Constants

This section is empty.

Variables

View Source
var ErrConfig = errors.New("smtp: incomplete configuration")

ErrConfig means a Config misses a value.

Functions

This section is empty.

Types

type AuthCheck added in v0.60.1

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

AuthCheck checks that a new key of the mail application authenticates with the SMTP server before it is put in service (#295). It implements app.CredentialInstaller, sends no mail and changes nothing.

func NewAuthCheck added in v0.60.1

func NewAuthCheck(opts AuthCheckOptions) (*AuthCheck, error)

NewAuthCheck returns an AuthCheck of opts, or ErrConfig.

func (*AuthCheck) InstallCredential added in v0.60.1

func (a *AuthCheck) InstallCredential(ctx context.Context, c app.Credential) error

InstallCredential authenticates with the secret key of c, until it succeeds or the attempts are over. Its errors name the access key of c, never its secret key.

type AuthCheckOptions added in v0.60.1

type AuthCheckOptions struct {
	// Addr is the host and port of the server, which speaks TLS at once,
	// such as "smtp.tem.scw.cloud:465"; Username is the user a key
	// authenticates as, its secret key being the password.
	Addr, Username string
	// HelloName is the domain sent with EHLO, such as "arnakoff.com".
	HelloName string
	// RootCAs are the authorities the server's certificate must chain to;
	// nil means those of the system.
	RootCAs *x509.CertPool
	// Attempts is the number of authentications tried, 6 when zero; Pause
	// the wait between two of them, a minute when zero.
	Attempts int
	Pause    time.Duration
	// Sleep waits d, or returns the error of ctx once it is done; the
	// system clock when nil.
	Sleep func(ctx context.Context, d time.Duration) error
}

AuthCheckOptions configures an AuthCheck.

type Config

type Config struct {
	// Addr is the host and port of the server, which speaks TLS at once,
	// such as "smtp.tem.scw.cloud:465".
	Addr string
	// Username and Password authenticate with AUTH PLAIN, sent over TLS
	// only.
	Username string
	Password []byte
	// From is the sender address.
	From domain.Email
	// RootCAs are the authorities the server's certificate must chain to;
	// nil means those of the system.
	RootCAs *x509.CertPool
	// Now dates the mails; nil means time.Now.
	Now func() time.Time
	// Random draws the message identifiers; nil means crypto/rand.Reader.
	Random io.Reader
}

Config configures a Sender.

type Sender

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

Sender sends plain text mails. It implements app.Mailer.

func New

func New(cfg Config) (*Sender, error)

New returns the Sender of cfg.

func (*Sender) Send

func (s *Sender) Send(ctx context.Context, to domain.Email, subject, body string) error

Send sends to to the plain text mail of subject and body. Its errors never quote the address, nor the server's replies, which may.

Jump to

Keyboard shortcuts

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