Help us shape the future of Go! Take the 2026 Go Developer Survey

mailer

package
v0.40.6 Latest Latest
Warning

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

Go to latest
Published: Oct 23, 2026 License: MIT Imports: 19 Imported by: 123

Documentation

Index

Constants

View Source
const (
	SMTPAuthPlain = "PLAIN"
	SMTPAuthLogin = "LOGIN"
)

Variables

This section is empty.

Functions

This section is empty.

Types

type Mailer

type Mailer interface {
	// Send sends an email with the provided Message.
	Send(message *Message) error
}

Mailer defines a base mail client interface.

type Message added in v0.9.0

type Message struct {
	From              mail.Address         `json:"from"`
	To                []mail.Address       `json:"to"`
	Bcc               []mail.Address       `json:"bcc"`
	Cc                []mail.Address       `json:"cc"`
	Subject           string               `json:"subject"`
	HTML              string               `json:"html"`
	Text              string               `json:"text"`
	Headers           map[string]string    `json:"headers"`
	Attachments       map[string]io.Reader `json:"attachments"`
	InlineAttachments map[string]io.Reader `json:"inlineAttachments"`
}

Message defines a generic email message struct.

type SMTPClient added in v0.23.0

type SMTPClient struct {
	TLS      bool
	Port     int
	Host     string
	Username string
	Password string

	// SMTP auth method to use
	// (if not explicitly set, defaults to "PLAIN")
	AuthMethod string

	// LocalName is optional domain name used for the EHLO/HELO exchange
	// (if not explicitly set, defaults to "localhost").
	//
	// This is required only by some SMTP servers, such as Gmail SMTP-relay.
	LocalName string
	// contains filtered or unexported fields
}

SMTPClient defines a SMTP mail client structure that implements `mailer.Mailer` interface.

func (*SMTPClient) OnSend added in v0.23.0

func (c *SMTPClient) OnSend() *hook.Hook[*SendEvent]

OnSend implements mailer.SendInterceptor interface.

func (*SMTPClient) Send added in v0.23.0

func (c *SMTPClient) Send(m *Message) error

Send implements mailer.Mailer interface.

type SendEvent added in v0.23.0

type SendEvent struct {
	hook.Event
	Message *Message
}

type SendInterceptor added in v0.23.0

type SendInterceptor interface {
	OnSend() *hook.Hook[*SendEvent]
}

SendInterceptor is optional interface for registering mail send hooks.

type Sendmail

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

Sendmail implements mailer.Mailer interface and defines a mail client that sends emails via the "sendmail" *nix command.

This client is usually recommended only for development and testing.

func (*Sendmail) OnSend added in v0.23.0

func (c *Sendmail) OnSend() *hook.Hook[*SendEvent]

OnSend implements mailer.SendInterceptor interface.

func (*Sendmail) Send

func (c *Sendmail) Send(m *Message) error

Send implements mailer.Mailer interface.

Jump to

Keyboard shortcuts

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