notifications

package
v0.29.1 Latest Latest
Warning

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

Go to latest
Published: Apr 12, 2024 License: MIT Imports: 12 Imported by: 0

Documentation

Overview

The contents of this files are modified libraris from the Go standard library. The original code can be found at https://cs.opensource.google/go/go/+/refs/tags/go1.22.2:src/net/smtp/smtp.go;l=321

Copyright belongs to the Go authors.

Index

Constants

View Source
const TLSPort = 465

Variables

View Source
var ErrTemplateNotFound = errors.New("template not found")

Functions

func PlainAuth

func PlainAuth(identity, username, password, host string) smtp.Auth

Types

type Email

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

func NewEmail

func NewEmail(
	host string,
	port uint16,
	useTLSConnection bool,
	auth smtp.Auth,
	from string,
	extraHeaders map[string]string,
	templates *Templates,
) *Email

func (*Email) Send

func (sm *Email) Send(to, subject, contents string, headers map[string]string) error

func (*Email) SendEmail added in v0.28.0

func (sm *Email) SendEmail(
	_ context.Context, to string, locale string, templateName TemplateName, data TemplateData,
) error

type TemplateData added in v0.28.0

type TemplateData struct {
	Link        string
	DisplayName string
	Email       string
	NewEmail    string
	Ticket      string
	RedirectTo  string
	Locale      string
	ServerURL   string
	ClientURL   string
}

func (TemplateData) ToMap added in v0.28.0

func (data TemplateData) ToMap(extra map[string]any) map[string]any

type TemplateName added in v0.28.0

type TemplateName string
const (
	TemplateNameEmailVerify        TemplateName = "email-verify"
	TemplateNameEmailConfirmChange TemplateName = "email-confirm-change"
	TemplateNameSigninPasswordless TemplateName = "signin-passwordless"
	TemplateNamePasswordReset      TemplateName = "password-reset"
)

type Templates

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

func NewTemplatesFromFilesystem

func NewTemplatesFromFilesystem(
	basePath string,
	defaultLocale string,
	logger *slog.Logger,
) (*Templates, error)

func (*Templates) GetRawTemplates

func (t *Templates) GetRawTemplates() map[string]*fasttemplate.Template

func (*Templates) GetTemplate

func (t *Templates) GetTemplate(
	templateName TemplateName, locale string,
) (
	*fasttemplate.Template, *fasttemplate.Template, error,
)

func (*Templates) Render added in v0.28.0

func (t *Templates) Render(
	locale string,
	templateName TemplateName,
	data TemplateData,
) (string, string, error)

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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