email

package
v1.7.0 Latest Latest
Warning

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

Go to latest
Published: Mar 15, 2026 License: GPL-3.0 Imports: 9 Imported by: 0

Documentation

Overview

Package email provides pluggable email sending for minimaldoc-server. Supports AWS SES, SMTP, SendGrid, and other providers.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Message

type Message struct {
	To          string
	Subject     string
	HTMLBody    string
	TextBody    string
	FromAddress string // Optional override
	FromName    string // Optional override
	ReplyTo     string
	Headers     map[string]string
}

Message represents an email message.

type MockSender

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

MockSender implements a mock email sender for testing.

func NewMockSender

func NewMockSender() *MockSender

NewMockSender creates a new mock email sender.

func (*MockSender) Clear

func (s *MockSender) Clear()

Clear removes all stored messages.

func (*MockSender) LastMessage

func (s *MockSender) LastMessage() *Message

LastMessage returns the most recently sent message.

func (*MockSender) Messages

func (s *MockSender) Messages() []*Message

Messages returns all sent messages.

func (*MockSender) Send

func (s *MockSender) Send(ctx context.Context, msg *Message) error

Send logs the email and stores it for inspection.

func (*MockSender) SendBulk

func (s *MockSender) SendBulk(ctx context.Context, msgs []*Message) error

SendBulk logs multiple emails and stores them.

type SMTPSender

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

SMTPSender implements email sending via SMTP.

func NewSMTPSender

func NewSMTPSender(cfg config.EmailConfig) (*SMTPSender, error)

NewSMTPSender creates a new SMTP email sender.

func (*SMTPSender) Send

func (s *SMTPSender) Send(ctx context.Context, msg *Message) error

Send sends an email to a single recipient.

func (*SMTPSender) SendBulk

func (s *SMTPSender) SendBulk(ctx context.Context, msgs []*Message) error

SendBulk sends emails to multiple recipients.

type Sender

type Sender interface {
	// Send sends an email to a single recipient.
	Send(ctx context.Context, msg *Message) error

	// SendBulk sends emails to multiple recipients.
	SendBulk(ctx context.Context, msgs []*Message) error
}

Sender defines the interface for email providers.

func NewSender

func NewSender(cfg config.EmailConfig) (Sender, error)

NewSender creates an email sender based on configuration. Currently supports: smtp, mock Future: ses, sendgrid (add when needed)

type TemplateData

type TemplateData struct {
	SiteName        string
	SiteURL         string
	RecipientEmail  string
	RecipientName   string
	VerificationURL string
	UnsubscribeURL  string
	Year            int
}

TemplateData contains common template variables.

type Templates

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

Templates provides email template rendering.

func NewTemplates

func NewTemplates(siteName, baseURL string) *Templates

NewTemplates creates a new template renderer.

func (*Templates) UnsubscribeEmail

func (t *Templates) UnsubscribeEmail(email string) *Message

UnsubscribeEmail generates an unsubscribe confirmation email.

func (*Templates) VerificationEmail

func (t *Templates) VerificationEmail(email, siteID, token string) *Message

VerificationEmail generates a newsletter verification email.

func (*Templates) WelcomeEmail

func (t *Templates) WelcomeEmail(email, siteID string) *Message

WelcomeEmail generates a welcome email after verification.

Jump to

Keyboard shortcuts

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