email

package
v0.0.0-...-befd928 Latest Latest
Warning

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

Go to latest
Published: Sep 1, 2026 License: AGPL-3.0 Imports: 15 Imported by: 0

Documentation

Index

Constants

View Source
const DATE_LAYOUT = "2006-01-02"
View Source
const DEFAULT_FOR_NO_VALUE = "n/a"

Variables

View Source
var (
	SMTP_HOST     = utils.GetEnv("SMTP_HOST", "")
	SMTP_PORT     = utils.GetEnv("SMTP_PORT", "2525")
	SMTP_USERNAME = utils.GetEnv("SMTP_USERNAME", "")
	SMTP_PASSWORD = utils.GetEnv("SMTP_PASSWORD", "")
)

Environment variables for SMTP configuration.

Functions

func BuildRawMessage

func BuildRawMessage(fromAddr string, data EmailData, attachment *PdfAttach) ([]byte, error)

BuildRawMessage constructs a MIME multipart/mixed raw message. If attachment is non-nil its bytes are included as a PDF attachment.

func RenderHtmlTemplate

func RenderHtmlTemplate(data any, templateBody string) (string, error)

func RenderTextTemplate

func RenderTextTemplate(data any, templateBody string) (string, error)

Types

type BatchEmailData

type BatchEmailData struct {
	FullCount   string
	ActualCount string
	BatchQuery  string
}

Only string fields are allowed

func GetBatchEmailData

func GetBatchEmailData(fullCount int64, actualCount int, batchQuery string) BatchEmailData

type DefaultMailer

type DefaultMailer struct{}

func (*DefaultMailer) SendMail

func (m *DefaultMailer) SendMail(addr string, a smtp.Auth, from string, to []string, msg []byte) error

type EmailData

type EmailData struct {
	To         []string `json:"to"`
	Subject    string   `json:"subject"`
	Body       string   `json:"body"`
	IsHTML     bool     `json:"isHtml,omitempty"`
	IncludePdf bool     `json:"includePdf,omitempty"`
}

EmailData carries the email payload inside an EventData.CustomData map.

type EmailService

type EmailService interface {
	SendEmail(from string, to []string, raw []byte) error
	IsReadyToSend() bool
}

type EmailServiceImpl

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

func NewEmailService

func NewEmailService() *EmailServiceImpl

func (*EmailServiceImpl) IsReadyToSend

func (s *EmailServiceImpl) IsReadyToSend() bool

func (*EmailServiceImpl) SendEmail

func (s *EmailServiceImpl) SendEmail(from string, to []string, raw []byte) error

type Mailer

type Mailer interface {
	SendMail(addr string, a smtp.Auth, from string, to []string, msg []byte) error
}

Mailer is an interface over smtp.SendMail, allowing mocking in tests.

type PdfAttach

type PdfAttach struct {
	Filename string
	Data     []byte
}

PdfAttach holds a PDF file to attach to the email.

type PullSlipData

type PullSlipData struct {
	ReqId            string
	PickupLocation   string
	Title            string
	Author           string
	DueDate          string
	ReturnAddress    string
	BarcodeBase64    string
	ServiceType      string
	ServiceLevel     string
	SystemIdentifier string
	Publisher        string
	Volume           string
	Issue            string
	Pages            string
	StaffNotes       string
	CallNumber       string
	LoanConditions   string
	PatronName       string
	PatronSurname    string
	PatronId         string
}

Only string fields are allowed

func GetPullSlipData

func GetPullSlipData(pr pr_db.PatronRequest, notes []pr_db.Notification, conditions []pr_db.Notification, barcodeData string) PullSlipData

Jump to

Keyboard shortcuts

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