guild

package
v0.2.0 Latest Latest
Warning

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

Go to latest
Published: May 13, 2023 License: Apache-2.0 Imports: 13 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var EmptyAddress = mail.Address{}

Functions

func LoadTemplateString

func LoadTemplateString(mightBeFilePath string) string

LoadTemplateString does some basic checks to determine if the input string might be a file path, and if so attempts to open the file for reading. If it is a readable file path, then it returns the contents of the file, otherwise returns the original string value.

func MakePongoContext

func MakePongoContext(srcCtx map[string]any) pongo.Context

func MakeTemplateContext added in v0.2.0

func MakeTemplateContext(srcCtx map[string]any) map[string]any

Types

type AddressType

type AddressType int
const (
	FromAddress AddressType = iota
	ReplyToAddress
	ToAddress
	CcAddress
	BccAddress
)

type Courier

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

Courier defines an smtp server/client responsible for "delivering" messages.

func NewCourier

func NewCourier(host string, port int, user, password string) *Courier

func (*Courier) Deliver

func (cr *Courier) Deliver(msg *smail.Email) error

Deliver provides a one-off connection and deliver of an email.

type Envelope

type Envelope struct {
	FromAddress    mail.Address
	ReplyToAddress mail.Address
	// contains filtered or unexported fields
}

func NewEnvelope

func NewEnvelope() *Envelope

func (*Envelope) AddBccAddress

func (em *Envelope) AddBccAddress(address string)

func (*Envelope) AddBccAddresses

func (em *Envelope) AddBccAddresses(addresses []string)

func (*Envelope) AddCcAddress

func (em *Envelope) AddCcAddress(address string)

func (*Envelope) AddCcAddresses

func (em *Envelope) AddCcAddresses(addresses []string)

func (*Envelope) AddToAddress

func (em *Envelope) AddToAddress(address string)

func (*Envelope) AddToAddresses

func (em *Envelope) AddToAddresses(addresses []string)

func (*Envelope) GetBccAddresses

func (em *Envelope) GetBccAddresses() []mail.Address

func (*Envelope) GetCcAddresses

func (em *Envelope) GetCcAddresses() []mail.Address

func (*Envelope) GetErrors

func (em *Envelope) GetErrors() error

func (*Envelope) GetToAddresses

func (em *Envelope) GetToAddresses() []mail.Address

func (*Envelope) HasErrors

func (em *Envelope) HasErrors() bool

func (*Envelope) SetFromAddress

func (em *Envelope) SetFromAddress(address string)

func (*Envelope) SetReplyToAddress

func (em *Envelope) SetReplyToAddress(address string)

func (*Envelope) Stamp

func (em *Envelope) Stamp(msg *smail.Email)

type Message

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

Message wraps an email struct

func NewMessage

func NewMessage() *Message

func (*Message) AddAttachment

func (c *Message) AddAttachment(filePath string, fileName string)

func (*Message) AddFile

func (c *Message) AddFile(file *smail.File)

func (*Message) Message

func (c *Message) Message() *smail.Email

Message returns the underlying Email struct

func (*Message) Seal

func (c *Message) Seal(envelope *Envelope)

Seal applies the envelope addressing to the email struct.

func (*Message) SetHtmlBody

func (c *Message) SetHtmlBody(html string)

SetHtmlBody sets the html email body, and flags the text body to be set as the alternative. Setting the html body with an empty string has no effect, other than to flag the text body as the primary.

func (*Message) SetPriority

func (c *Message) SetPriority(isHigh bool)

func (*Message) SetPriorityHigh

func (c *Message) SetPriorityHigh()

func (*Message) SetPriorityLow

func (c *Message) SetPriorityLow()

func (*Message) SetSubject

func (c *Message) SetSubject(subject string)

SetSubject sets the email subject to the provided string value.

func (*Message) SetTextBody

func (c *Message) SetTextBody(text string)

SetTextBody sets the raw text email body. If the text body has been set after the Html body, it is set as the alternative body of the email, otherwise it will be treated as the primary. Setting the text body with an empty string has no effect.

func (*Message) String

func (c *Message) String() string

String returns the raw email text.

type PongoScribe

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

PongoScribe

func NewPongoScribe

func NewPongoScribe() *PongoScribe

func (*PongoScribe) Close

func (ps *PongoScribe) Close()

func (*PongoScribe) Compose

func (ps *PongoScribe) Compose(ctx ...any) Scribe

func (*PongoScribe) GetErrors

func (ps *PongoScribe) GetErrors() error

func (*PongoScribe) HasErrors

func (ps *PongoScribe) HasErrors() bool

func (*PongoScribe) Include

func (ps *PongoScribe) Include(filepath string, name ...string)

func (*PongoScribe) Message

func (ps *PongoScribe) Message() *smail.Email

func (*PongoScribe) Open

func (ps *PongoScribe) Open() (*Message, error)

func (*PongoScribe) Seal

func (ps *PongoScribe) Seal(envelope *Envelope) Scribe

func (*PongoScribe) SetBodyTemplate

func (ps *PongoScribe) SetBodyTemplate(text string, html bool)

func (*PongoScribe) SetHtmlBodyTemplate

func (ps *PongoScribe) SetHtmlBodyTemplate(html string)

func (*PongoScribe) SetPriority

func (ps *PongoScribe) SetPriority(isHigh bool)

func (*PongoScribe) SetSubjectTemplate

func (ps *PongoScribe) SetSubjectTemplate(subject string)

func (*PongoScribe) SetTextBodyTemplate

func (ps *PongoScribe) SetTextBodyTemplate(text string)

type Scribe

type Scribe interface {
	SetPriority(bool)
	SetSubjectTemplate(string)
	SetTextBodyTemplate(string)
	SetHtmlBodyTemplate(string)
	SetBodyTemplate(string, bool)
	Include(string, ...string)
	Open() (*Message, error)
	Close()
	Seal(*Envelope) Scribe
	Compose(...any) Scribe
	Message() *smail.Email
	HasErrors() bool
	GetErrors() error
}

Scribe creates messages.

type SimpleTextScribe

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

SimpleTextScribe renders plain static text for the email body.

func NewSimpleTextScribe

func NewSimpleTextScribe() *SimpleTextScribe

func (*SimpleTextScribe) Close

func (sts *SimpleTextScribe) Close()

func (*SimpleTextScribe) Compose

func (sts *SimpleTextScribe) Compose(ctx ...any) Scribe

func (*SimpleTextScribe) GetErrors

func (sts *SimpleTextScribe) GetErrors() error

func (*SimpleTextScribe) HasErrors

func (sts *SimpleTextScribe) HasErrors() bool

func (*SimpleTextScribe) Include

func (sts *SimpleTextScribe) Include(filepath string, name ...string)

func (*SimpleTextScribe) Message

func (sts *SimpleTextScribe) Message() *smail.Email

func (*SimpleTextScribe) Open

func (sts *SimpleTextScribe) Open() (*Message, error)

func (*SimpleTextScribe) Seal

func (sts *SimpleTextScribe) Seal(envelope *Envelope) Scribe

func (*SimpleTextScribe) SetBodyTemplate

func (sts *SimpleTextScribe) SetBodyTemplate(text string, html bool)

func (*SimpleTextScribe) SetHtmlBodyTemplate

func (sts *SimpleTextScribe) SetHtmlBodyTemplate(html string)

func (*SimpleTextScribe) SetPriority

func (sts *SimpleTextScribe) SetPriority(isHigh bool)

func (*SimpleTextScribe) SetSubjectTemplate

func (sts *SimpleTextScribe) SetSubjectTemplate(subject string)

func (*SimpleTextScribe) SetTextBodyTemplate

func (sts *SimpleTextScribe) SetTextBodyTemplate(text string)

type TemplateScribe added in v0.2.0

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

TemplateScribe

func NewTemplateScribe added in v0.2.0

func NewTemplateScribe() *TemplateScribe

func (*TemplateScribe) Close added in v0.2.0

func (ps *TemplateScribe) Close()

func (*TemplateScribe) Compose added in v0.2.0

func (ps *TemplateScribe) Compose(ctx ...any) Scribe

func (*TemplateScribe) GetErrors added in v0.2.0

func (ps *TemplateScribe) GetErrors() error

func (*TemplateScribe) HasErrors added in v0.2.0

func (ps *TemplateScribe) HasErrors() bool

func (*TemplateScribe) Include added in v0.2.0

func (ps *TemplateScribe) Include(filepath string, name ...string)

func (*TemplateScribe) Message added in v0.2.0

func (ps *TemplateScribe) Message() *smail.Email

func (*TemplateScribe) Open added in v0.2.0

func (ps *TemplateScribe) Open() (*Message, error)

func (*TemplateScribe) Seal added in v0.2.0

func (ps *TemplateScribe) Seal(envelope *Envelope) Scribe

func (*TemplateScribe) SetBodyTemplate added in v0.2.0

func (ps *TemplateScribe) SetBodyTemplate(text string, html bool)

func (*TemplateScribe) SetHtmlBodyTemplate added in v0.2.0

func (ps *TemplateScribe) SetHtmlBodyTemplate(html string)

func (*TemplateScribe) SetPriority added in v0.2.0

func (ps *TemplateScribe) SetPriority(isHigh bool)

func (*TemplateScribe) SetSubjectTemplate added in v0.2.0

func (ps *TemplateScribe) SetSubjectTemplate(subject string)

func (*TemplateScribe) SetTextBodyTemplate added in v0.2.0

func (ps *TemplateScribe) SetTextBodyTemplate(text string)

Jump to

Keyboard shortcuts

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