mail

package
v0.16.0 Latest Latest
Warning

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

Go to latest
Published: Oct 21, 2026 License: Apache-2.0 Imports: 9 Imported by: 0

Documentation

Overview

Package mail sends plain-text email over SMTP. Auth uses it to deliver one-time login codes; the Sender interface lets tests substitute a fake.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Message

func Message(from, to, subject, body string, now time.Time) ([]byte, error)

Message renders an RFC 5322 plain-text message with CRLF line endings. Header values containing a line break are rejected (header injection).

Types

type SMTPSender

type SMTPSender struct {
	Host     string
	Port     string
	User     string
	Password string
	From     string
}

SMTPSender sends through a single SMTP server. Port 465 uses implicit TLS; any other port uses STARTTLS when the server offers it. PLAIN auth is used only when User is set, so an unauthenticated local relay works.

func NewSMTPSenderFromEnv

func NewSMTPSenderFromEnv() (*SMTPSender, bool)

NewSMTPSenderFromEnv builds a sender from smtp_host, smtp_port (default 587), smtp_user, smtp_password and smtp_from. ok is false when smtp_host or smtp_from is unset, meaning email login is not configured.

func (*SMTPSender) Send

func (s *SMTPSender) Send(to, subject, body string) error

Send delivers one message to a single recipient.

type Sender

type Sender interface {
	Send(to, subject, body string) error
}

Sender delivers a plain-text email.

Jump to

Keyboard shortcuts

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