email

package
v0.0.0-...-bf444b6 Latest Latest
Warning

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

Go to latest
Published: Aug 18, 2024 License: AGPL-3.0 Imports: 5 Imported by: 0

Documentation

Index

Constants

View Source
const (
	MimeTypeHTML      = "text/html"
	MimeTypePlainText = "text/plain"
)

Variables

View Source
var (
	ErrInvalidLicenseExpiryTemplateData      = errors.New("invalid license expiration template data")  // invalid license expiration template data
	ErrInvalidOrganizationInviteTemplateData = errors.New("invalid organization invite template data") // invalid organization invite template data
	ErrInvalidPasswordResetTemplateData      = errors.New("invalid password reset template data")      // invalid password reset template data
	ErrInvalidUserWelcomeTemplateData        = errors.New("invalid welcome template data")             // invalid welcome template data
	ErrTemplateExecute                       = errors.New("failed to execute email template")          // failed to execute email template
	ErrTemplateInvalid                       = errors.New("invalid template")                          // invalid template
	ErrTemplateParse                         = errors.New("failed to parse email template")            // failed to parse email template
)

Functions

This section is empty.

Types

type Executor

type Executor interface {
	Execute(wr io.Writer, data any) error
}

Executor executes parsed templates.

type LicenseExpiryTemplateData

type LicenseExpiryTemplateData struct {
	Subject             string `validate:"required,min=3,max=50"`
	LicenseID           string `validate:"required"`
	LicenseEmail        string `validate:"required,email"`
	LicenseOrganization string `validate:"required"`
	LicenseExpiresAt    string `validate:"required"`
	ServerURL           string `validate:"required,url"`
	RenewEmail          string `validate:"required,email"`
	SupportEmail        string `validate:"required,email"`
}

LicenseExpiryTemplateData represents the data needed to render the password reset email template.

func (*LicenseExpiryTemplateData) Get

func (d *LicenseExpiryTemplateData) Get() interface{}

Get returns the license expiration email template data.

type OrganizationInviteTemplateData

type OrganizationInviteTemplateData struct {
	Subject          string `validate:"required,min=3,max=50"`
	Username         string `validate:"required,min=3,max=50"`
	FirstName        string `validate:"omitempty,max=50"`
	OrganizationName string `validate:"required,min=3,max=50"`
	InvitationURL    string `validate:"required,url"`
	SupportEmail     string `validate:"required,email"`
}

OrganizationInviteTemplateData represents the data needed to render the invitation email template.

func (*OrganizationInviteTemplateData) Get

func (d *OrganizationInviteTemplateData) Get() interface{}

Get returns the invitation email template data.

type PasswordResetTemplateData

type PasswordResetTemplateData struct {
	Subject          string `validate:"required,min=3,max=50"`
	Username         string `validate:"required,min=3,max=50"`
	FirstName        string `validate:"omitempty,max=50"`
	PasswordResetURL string `validate:"required,url"`
	SupportEmail     string `validate:"required,email"`
}

PasswordResetTemplateData represents the data needed to render the password reset email template.

func (*PasswordResetTemplateData) Get

func (d *PasswordResetTemplateData) Get() interface{}

Get returns the password reset email template data.

type Template

type Template struct {
	Path string       `validate:"required,filepath"`
	Data TemplateData `validate:"required"`
}

Template is a struct that represents the data needed to render an email template.

func NewTemplate

func NewTemplate(path string, data TemplateData) (*Template, error)

NewTemplate returns a new email template.

func (*Template) Render

func (t *Template) Render() (string, error)

Render returns the rendered template.

func (*Template) Validate

func (t *Template) Validate() error

Validate validates the password reset email template.

type TemplateData

type TemplateData interface {
	// Get returns the template data.
	Get() any
}

TemplateData represents the data needed to render an email template.

type TemplateParserFunc

type TemplateParserFunc[T Executor] func(filenames ...string) (T, error)

TemplateParserFunc parses email templates.

type UserWelcomeTemplateData

type UserWelcomeTemplateData struct {
	Subject      string `validate:"required,min=3,max=50"`
	Username     string `validate:"required,min=3,max=50"`
	FirstName    string `validate:"omitempty,max=50"`
	LoginURL     string `validate:"required,url"`
	SupportEmail string `validate:"required,email"`
}

UserWelcomeTemplateData represents the data needed to render the welcome email template.

func (*UserWelcomeTemplateData) Get

func (d *UserWelcomeTemplateData) Get() interface{}

Get returns the welcome email template data.

Jump to

Keyboard shortcuts

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