mail

package module
v0.0.0-...-4af4644 Latest Latest
Warning

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

Go to latest
Published: Oct 18, 2020 License: MIT Imports: 14 Imported by: 1

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Attachment

type Attachment struct {
	Name    string `json:"name"`
	Kind    string `json:"kind"`
	Content []byte `json:"content"`
}

Attachment is attachment for message send via smtp server

type ConfigurableRecorder

type ConfigurableRecorder interface {
	ConfigurableSender
	Recorder
	TxConfig() *TxConfig
}

type ConfigurableSender

type ConfigurableSender interface {
	Sender
	// UpdateTxConfig must be safe for concurrenct use
	UpdateTxConfig(cfg TxConfig)
}

type Mail

type Mail struct {
	From    string
	To      To
	Message Message
}

type MemRecorder

type MemRecorder struct {
	Mails []Mail
	// contains filtered or unexported fields
}

func (*MemRecorder) Seen

func (r *MemRecorder) Seen(m Mail) (ok bool, err error)

func (*MemRecorder) Send

func (r *MemRecorder) Send(from string, to To, message Message, options ...SendOption) (err error)

func (*MemRecorder) TxConfig

func (r *MemRecorder) TxConfig() TxConfig

func (*MemRecorder) UpdateTxConfig

func (r *MemRecorder) UpdateTxConfig(cfg TxConfig)

type Message

type Message struct {
	Topic       string       `json:"topic"`
	Body        string       `json:"body"`
	Attachments []Attachment `json:"attachments"`
	ContentType string       `json:"contentType"`
}

Message is message send via smtp server

type Option

type Option func(*Template)

Option option to configure template

func AllowAttachments

func AllowAttachments(types ...string) Option

AllowAttachments allows attachements for letter

func ContentType

func ContentType(kind string) Option

ContentType is content-type of message

func TemplateFuncs

func TemplateFuncs(funcs template.FuncMap) Option

TemplateFuncs merge template funcs with default template funcs for letter

func WithAttachments

func WithAttachments(attachments RequestAttachments) Option

WithAttachments add attacments to a message

type Recorder

type Recorder interface {
	Sender
	Seen(Mail) (ok bool, err error)
}

type RequestAttachment

type RequestAttachment struct {
	Name string `json:"name"`
	// Content base64 encoded content
	Content []byte `json:"content"`
}

RequestAttachment can be used in the request struct when attachments are allowed

type RequestAttachments

type RequestAttachments []RequestAttachment

RequestAttachments list of RequestAttachments

type SendOption

type SendOption interface {
	// contains filtered or unexported methods
}

func AsCc

func AsCc() SendOption

type Sender

type Sender interface {
	Send(from string, to To, message Message, options ...SendOption) (err error)
}

type Template

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

Template template for message

func NewTemplate

func NewTemplate(topic, body string, options ...Option) (tpl Template, err error)

NewTemplate creates new template

func (Template) Execute

func (tpl Template) Execute(data interface{}, opts ...Option) (msg Message, err error)

Execute builds message with given data and options

type To

type To []string

To represents to addresses

type Tx

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

func Dial

func Dial(cfg TxConfig) (tx *Tx, err error)

Dial creates a new smtp transmitter and creates a dialer with passed config.

func New

func New() (tx *Tx)

New creates a new smtp transmitter

func (*Tx) Send

func (tx *Tx) Send(from string, to To, message Message, options ...SendOption) (err error)

Send sends message

func (*Tx) UpdateTxConfig

func (tx *Tx) UpdateTxConfig(cfg TxConfig)

UpdateTxConfig tx config. Is safe for concurrenct use.

type TxConfig

type TxConfig struct {
	User     string `json:"user" ini:"user" yaml:"user"`
	Password string `json:"password" ini:"password" yaml:"password"`
	Host     string `json:"host" ini:"host" yaml:"host"`
	Port     int    `json:"port" ini:"port" yaml:"port"`
	TmpDir   string `json:"tmpDir" ini:"tmp-dir" envconfig:"TMP_DIR" yaml:"tmpDir"`
}

func (TxConfig) Validate

func (cfg TxConfig) Validate() error

Jump to

Keyboard shortcuts

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