mailsender

package
v0.2.0 Latest Latest
Warning

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

Go to latest
Published: Nov 7, 2026 License: MIT Imports: 14 Imported by: 0

Documentation

Overview

Package mailsender sends transactional email via SMTP.

Index

Constants

This section is empty.

Variables

View Source
var ErrBadAddress = errors.New("not an e-mail address")

ErrBadAddress - the recipient isn't one e-mail address.

Functions

This section is empty.

Types

type EmailConfig

type EmailConfig struct {
	SMTPHost     string
	SMTPPort     int
	SMTPUser     string
	SMTPPassword string
	FromAddress  string
	// Timeout bounds the whole SMTP session (0 - defaultSMTPTimeout).
	Timeout time.Duration
}

EmailConfig holds SMTP configuration (can be populated from config package)

type EmailSender

type EmailSender interface {
	// SendPlain sends a transactional email with explicit subject and body (UTF-8 plain text).
	SendPlain(to, subject, body string) error
}

EmailSender sends emails (password reset, notifications, etc.)

type NoopEmailSender

type NoopEmailSender struct{}

NoopEmailSender is a no-op implementation for when email is not configured

func (NoopEmailSender) SendPlain

func (NoopEmailSender) SendPlain(to, subject, body string) error

SendPlain does nothing

type SMTPEmailSender

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

SMTPEmailSender sends emails via SMTP

func NewSMTPEmailSender

func NewSMTPEmailSender(cfg EmailConfig) *SMTPEmailSender

NewSMTPEmailSender creates a new SMTP email sender

func (*SMTPEmailSender) SendPlain

func (s *SMTPEmailSender) SendPlain(to, subject, body string) error

SendPlain sends UTF-8 plain text email.

Jump to

Keyboard shortcuts

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