mailer

package
v1.2.3 Latest Latest
Warning

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

Go to latest
Published: May 6, 2026 License: MIT Imports: 13 Imported by: 0

Documentation

Index

Constants

View Source
const (
	SMTPSecretHostKey     = "ozy.smtp.host"
	SMTPSecretPortKey     = "ozy.smtp.port"
	SMTPSecretUsernameKey = "ozy.smtp.username"
	SMTPSecretPasswordKey = "ozy.smtp.password"
	SMTPSecretFromKey     = "ozy.smtp.from"
)

Variables

This section is empty.

Functions

func IsManagedSMTPSecretKey

func IsManagedSMTPSecretKey(key string) bool

func LoadSMTPConfig

func LoadSMTPConfig(ctx context.Context, db *data.DB, fallback SMTPConfig) (SMTPConfig, SMTPConfigSource, error)

func SaveSMTPConfig

func SaveSMTPConfig(ctx context.Context, db *data.DB, cfg SMTPConfig, preservePassword, clearPassword bool) error

func SendTemplateEmail

func SendTemplateEmail(ctx context.Context, db *data.DB, sender Mailer, templateType, to string, variables map[string]string) error

Types

type LogMailer

type LogMailer struct{}

LogMailer is a console fallback mailer used when SMTP is not configured.

func NewLogMailer

func NewLogMailer() *LogMailer

func (*LogMailer) Send

func (m *LogMailer) Send(to, subject, body string) error

func (*LogMailer) SendPasswordResetEmail

func (m *LogMailer) SendPasswordResetEmail(to, token string) error

func (*LogMailer) SendSecurityAlert

func (m *LogMailer) SendSecurityAlert(to, alertType, details string) error

func (*LogMailer) SendVerificationEmail

func (m *LogMailer) SendVerificationEmail(to, token string) error

func (*LogMailer) SendWorkspaceInvite

func (m *LogMailer) SendWorkspaceInvite(to, workspaceName, inviterEmail string) error

type Mailer

type Mailer interface {
	Send(to, subject, body string) error
	SendVerificationEmail(to, token string) error
	SendPasswordResetEmail(to, token string) error
	SendSecurityAlert(to, alertType, details string) error
	SendWorkspaceInvite(to, workspaceName, inviterEmail string) error
}

Mailer defines the interface for sending emails

func NewRuntimeMailer

func NewRuntimeMailer(db *data.DB, fallback SMTPConfig) Mailer

type RuntimeMailer

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

func (*RuntimeMailer) Send

func (m *RuntimeMailer) Send(to, subject, body string) error

func (*RuntimeMailer) SendPasswordResetEmail

func (m *RuntimeMailer) SendPasswordResetEmail(to, token string) error

func (*RuntimeMailer) SendSecurityAlert

func (m *RuntimeMailer) SendSecurityAlert(to, alertType, details string) error

func (*RuntimeMailer) SendVerificationEmail

func (m *RuntimeMailer) SendVerificationEmail(to, token string) error

func (*RuntimeMailer) SendWorkspaceInvite

func (m *RuntimeMailer) SendWorkspaceInvite(to, workspaceName, inviterEmail string) error

type SMTPConfig

type SMTPConfig struct {
	Host     string
	Port     string
	Username string
	Password string
	From     string
}

func SMTPConfigFromEnvironment

func SMTPConfigFromEnvironment() SMTPConfig

func (SMTPConfig) Configured

func (c SMTPConfig) Configured() bool

func (SMTPConfig) Validate

func (c SMTPConfig) Validate() error

type SMTPConfigSource

type SMTPConfigSource string
const (
	SMTPConfigSourceConsole     SMTPConfigSource = "console"
	SMTPConfigSourceEnvironment SMTPConfigSource = "environment"
	SMTPConfigSourceDatabase    SMTPConfigSource = "database"
)

type SMTPMailer

type SMTPMailer struct {
	Host     string
	Port     string
	Username string
	Password string
	From     string
}

SMTPMailer implementation

func NewSMTPMailer

func NewSMTPMailer(host, port, user, pass, from string) *SMTPMailer

func (*SMTPMailer) Send

func (m *SMTPMailer) Send(to, subject, body string) error

func (*SMTPMailer) SendPasswordResetEmail

func (m *SMTPMailer) SendPasswordResetEmail(to, token string) error

func (*SMTPMailer) SendSecurityAlert

func (m *SMTPMailer) SendSecurityAlert(to, alertType, details string) error

func (*SMTPMailer) SendVerificationEmail

func (m *SMTPMailer) SendVerificationEmail(to, token string) error

func (*SMTPMailer) SendWorkspaceInvite

func (m *SMTPMailer) SendWorkspaceInvite(to, workspaceName, inviterEmail string) error

Jump to

Keyboard shortcuts

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