mail

package
v0.3.1 Latest Latest
Warning

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

Go to latest
Published: Jun 7, 2025 License: MIT Imports: 15 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 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