messenger

package
v0.5.0-alpha Latest Latest
Warning

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

Go to latest
Published: Mar 8, 2020 License: AGPL-3.0 Imports: 6 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func MakeAttachmentHeader

func MakeAttachmentHeader(filename, encoding string) textproto.MIMEHeader

MakeAttachmentHeader is a helper function that returns a textproto.MIMEHeader tailored for attachments, primarily email. If no encoding is given, base64 is assumed.

Types

type Attachment

type Attachment struct {
	Name    string
	Header  textproto.MIMEHeader
	Content []byte
}

Attachment represents a file or blob attachment that can be sent along with a message by a Messenger.

type Messenger

type Messenger interface {
	Name() string

	Push(fromAddr string, toAddr []string, subject string, message []byte, atts []*Attachment) error
	Flush() error
}

Messenger is an interface for a generic messaging backend, for instance, e-mail, SMS etc.

func NewEmailer

func NewEmailer(srv ...Server) (Messenger, error)

NewEmailer creates and returns an e-mail Messenger backend. It takes multiple SMTP configurations.

type Server

type Server struct {
	Name          string
	Host          string        `koanf:"host"`
	Port          int           `koanf:"port"`
	AuthProtocol  string        `koanf:"auth_protocol"`
	Username      string        `koanf:"username"`
	Password      string        `koanf:"password"`
	HelloHostname string        `koanf:"hello_hostname"`
	SendTimeout   time.Duration `koanf:"send_timeout"`
	MaxConns      int           `koanf:"max_conns"`
	// contains filtered or unexported fields
}

Server represents an SMTP server's credentials.

Jump to

Keyboard shortcuts

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