notify

package
v0.3.1 Latest Latest
Warning

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

Go to latest
Published: Sep 3, 2021 License: MIT Imports: 14 Imported by: 0

Documentation

Overview

Package notify provides email sender

Package notify providers error delivery via email

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Email

type Email struct {
	SMTPClient
	EmailParams
}

Email implements sender interface for VerifyHandler Uses common subject line and "from" for all messages

func NewEmailClient

func NewEmailClient(p EmailParams) *Email

NewEmailClient creates email client with prepared smtp

func (*Email) IsOnCompletion

func (em *Email) IsOnCompletion() bool

IsOnCompletion status enabling on-passed notification

func (*Email) IsOnError

func (em *Email) IsOnError() bool

IsOnError status enabling on-error notification

func (*Email) Send

func (em *Email) Send(subj, text string) error

Send email with given text and subject If SMTPClient defined in Email struct it will be used, if not - new smtp.Client on each send. Always closes client on completion or failure. nolint gocyclo

type EmailParams

type EmailParams struct {
	Host         string // SMTP host
	Port         int    // SMTP port
	From         string // From email field
	ContentType  string // Content type, optional. Will trigger MIME and Content-Type headers
	To           []string
	TLS          bool   // TLS auth
	SMTPUserName string // user name
	SMTPPassword string // password
	TimeOut      time.Duration

	OnError      bool
	OnCompletion bool
}

EmailParams with all needed to make new Email client with smtp

type SMTPClient

type SMTPClient interface {
	Mail(string) error
	Auth(smtp.Auth) error
	Rcpt(string) error
	Data() (io.WriteCloser, error)
	Quit() error
	Close() error
}

SMTPClient interface defines subset of net/smtp used by email client

type Service added in v0.2.0

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

Service warps email client and template management

func NewService added in v0.2.0

func NewService(email *Email, errTmplFile, complTmplFile string) *Service

NewService makes notification service with optional template files

func (Service) MakeCompletionHTML added in v0.2.0

func (s Service) MakeCompletionHTML(spec, command string) (string, error)

MakeCompletionHTML creates error html body from completionTemplate

func (Service) MakeErrorHTML added in v0.2.0

func (s Service) MakeErrorHTML(spec, command, errorLog string) (string, error)

MakeErrorHTML creates error html body from errorTemplate

Jump to

Keyboard shortcuts

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