mail

package module
v0.1.0 Latest Latest
Warning

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

Go to latest
Published: Jun 22, 2026 License: MIT Imports: 9 Imported by: 0

README

mail

Email for togo: a Mailer contract with an SMTP driver (default) and a dev log driver. AWS SES, Resend, etc. ship as driver plugins that call mail.RegisterDriver.

togo install togo-framework/mail

Env: MAIL_DRIVER (smtp|log), MAIL_HOST, MAIL_PORT, MAIL_USERNAME, MAIL_PASSWORD, MAIL_FROM, MAIL_ENCRYPTION (tls|starttls|none).

Documentation

Overview

Package mail is togo's email subsystem: a Mailer contract with an SMTP driver (default) and a dev "log" driver. Additional providers (AWS SES, Resend, …) ship as driver plugins that call mail.RegisterDriver and depend on this package. Used by auth for OTP/verification/reset flows.

Install: `togo install togo-framework/mail` (blank-import registers it).

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func RegisterDriver

func RegisterDriver(name string, f DriverFactory)

RegisterDriver registers a mail driver by name (call from a plugin's init()).

Types

type DriverFactory

type DriverFactory func(k *togo.Kernel) (Mailer, error)

DriverFactory builds a Mailer from the kernel (env-configured).

type Mailer

type Mailer interface {
	Send(ctx context.Context, m Message) error
}

Mailer sends messages. Drivers (smtp, resend, ses, …) implement it.

type Message

type Message struct {
	From    string
	To      []string
	Cc      []string
	Bcc     []string
	Subject string
	Text    string // plain-text body
	HTML    string // optional HTML body
}

Message is an email to send.

type Service

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

Service is the mail runtime stored on the kernel (k.Get("mail")).

func FromKernel

func FromKernel(k *togo.Kernel) (*Service, bool)

FromKernel fetches the mail service from the kernel container.

func (*Service) Driver

func (s *Service) Driver() string

Driver returns the active driver name.

func (*Service) Send

func (s *Service) Send(ctx context.Context, m Message) error

Send dispatches a message via the configured driver.

Jump to

Keyboard shortcuts

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