mailtemplate

package
v0.1.0 Latest Latest
Warning

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

Go to latest
Published: Nov 5, 2026 License: MIT Imports: 2 Imported by: 0

Documentation

Overview

Package mailtemplate substitutes [site:...]/[user:...] placeholders, and a module's own (TokenData.Extra), in email subject/body templates.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func ReplacePlaceholders

func ReplacePlaceholders(tpl string, d TokenData) string

ReplacePlaceholders substitutes [token] placeholders in template text (plain).

Types

type Mailer

type Mailer interface {
	Send(ctx context.Context, key, to string, data TokenData) error
}

Mailer sends one of the site's emails by its key: the site keeps its template and whether it is sent; data fills in the placeholders.

type TokenData

type TokenData struct {
	SiteName             string
	SiteSlogan           string
	SiteLoginURL         string
	SiteURLBrief         string // scheme + host, no path
	SitePeoplePendingURL string
	UserName             string
	UserEmail            string
	ConfirmEmailURL      string // /user/confirm-email?token=
	OneTimeLoginURL      string
	ResetPasswordURL     string // /user/reset-password?token=
	UserEditURL          string
	// Extra - a module's own placeholders and their values
	// ("[pm:sender]" → a name), substituted after the ones above.
	Extra map[string]string
}

TokenData holds values for [site:...] and [user:...] placeholders in email bodies/subjects, and a module's own in Extra.

Jump to

Keyboard shortcuts

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