mail

package
v0.5.3 Latest Latest
Warning

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

Go to latest
Published: Oct 19, 2025 License: MIT Imports: 18 Imported by: 0

Documentation

Overview

Package mail provides a mail service

Index

Constants

This section is empty.

Variables

View Source
var TemplatesFS embed.FS

Functions

func MailWorker added in v0.0.8

func MailWorker(mailQueue chan Mail, mailErr chan error, worker int)

Worker processes emails from the mail queue nolint:revive // Keeping original name for backward compatibility

func ProcessMail added in v0.0.8

func ProcessMail(mailData Mail) error

ProcessMail handles the actual sending of an email

Types

type EmbeddedImage added in v0.0.11

type EmbeddedImage struct {
	ContentID string // ContentID to be referenced in HTML, e.g., <img src="cid:image1">
	Path      string // Path to the image file
	Data      []byte // Raw image data (optional, used if Path is empty)
}

EmbeddedImage represents an image to be embedded in an email

type InstrumentedMailService added in v0.4.0

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

InstrumentedMailService wraps the mail functionality with metrics collection

func NewInstrumentedMailService added in v0.4.0

func NewInstrumentedMailService(systemMetrics *metrics.SystemHealthMetrics) *InstrumentedMailService

NewInstrumentedMailService creates a new instrumented mail service

func (*InstrumentedMailService) GetMailQueueDepth added in v0.4.0

func (ims *InstrumentedMailService) GetMailQueueDepth() int64

GetMailQueueDepth returns the current depth of the mail queue

func (*InstrumentedMailService) GetSystemHealthCallbacks added in v0.4.0

func (ims *InstrumentedMailService) GetSystemHealthCallbacks() (
	getMailQueueDepth func() int64,
	getWorkerCount func() int64,
)

GetSystemHealthCallbacks returns callback functions for system health metrics

func (*InstrumentedMailService) GetSystemStatus added in v0.4.0

func (ims *InstrumentedMailService) GetSystemStatus() int64

GetSystemStatus returns the overall mail system health status Returns 1 if healthy, 0 if unhealthy

func (*InstrumentedMailService) GetWorkerCount added in v0.4.0

func (ims *InstrumentedMailService) GetWorkerCount() int64

GetWorkerCount returns the current number of active mail workers

func (*InstrumentedMailService) InstrumentedMailWorker added in v0.4.0

func (ims *InstrumentedMailService) InstrumentedMailWorker(mailQueue chan Mail, mailErr chan error, workerCount int)

InstrumentedMailWorker is an instrumented version of MailWorker that tracks metrics

func (*InstrumentedMailService) ProcessMailWithMetrics added in v0.4.0

func (ims *InstrumentedMailService) ProcessMailWithMetrics(ctx context.Context, mailData Mail) error

ProcessMailWithMetrics wraps ProcessMail with metrics collection

func (*InstrumentedMailService) StartInstrumentedMailWorkers added in v0.4.0

func (ims *InstrumentedMailService) StartInstrumentedMailWorkers(mailQueue chan Mail, mailErr chan error, workerCount int)

StartInstrumentedMailWorkers starts the instrumented mail workers This is a drop-in replacement for the original MailWorker function

type Mail added in v0.0.8

type Mail struct {
	FromName     string
	FromEmail    string
	To           string
	Subject      string
	Body         string          // Plain text body (used only if Template is empty)
	HTMLBody     string          // HTML body (used only if Template is empty)
	Template     string          // Template name to use
	TemplateData interface{}     // Data to pass to the template
	Attachments  []string        // Paths to files to attach
	Images       []EmbeddedImage // Images to embed in the email
	MetaData     interface{}     // Additional metadata
}

Mail is a struct that holds the data for a mail

func NewMail added in v0.0.11

func NewMail(to string, subject string, template string, templateData interface{}) *Mail

func (*Mail) AttachFile added in v0.0.11

func (m *Mail) AttachFile(filepath string) error

AttachFile adds a file to the email attachments

func (*Mail) Send added in v0.0.8

func (m *Mail) Send() error

Send queues a mail for sending

type TemplateEngine added in v0.0.11

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

TemplateEngine handles email template rendering

var (
	MailQueue            chan Mail
	GlobalTemplateEngine *TemplateEngine
)

func GetTemplateEngine added in v0.0.11

func GetTemplateEngine() *TemplateEngine

GetTemplateEngine returns the global template engine instance

func (*TemplateEngine) Init added in v0.0.11

func (te *TemplateEngine) Init() error

Init initializes the template engine by loading all templates

func (*TemplateEngine) Render added in v0.0.11

func (te *TemplateEngine) Render(templateName string, data interface{}) (string, string, error)

Render renders a template with the given data

Jump to

Keyboard shortcuts

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