mailservice

package
v1.18.3-rc-1 Latest Latest
Warning

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

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

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Config

type Config struct {
	SMTPServerAddress string `help:"smtp server address" default:""`
	TemplatePath      string `help:"path to email templates source" default:""`
	From              string `help:"sender email address" default:""`
	AuthType          string `help:"smtp authentication type" releaseDefault:"login" devDefault:"simulate"`
	Login             string `help:"plain/login auth user login" default:""`
	Password          string `help:"plain/login auth user password" default:""`
	RefreshToken      string `help:"refresh token used to retrieve new access token" default:""`
	ClientID          string `help:"oauth2 app's client id" default:""`
	ClientSecret      string `help:"oauth2 app's client secret" default:""`
	TokenURI          string `help:"uri which is used when retrieving new access token" default:""`
}

Config defines values needed by mailservice service.

type Message

type Message interface {
	Template() string
	Subject() string
}

Message defines mailservice template-backed message for SendRendered method.

type Sender

type Sender interface {
	SendEmail(ctx context.Context, msg *post.Message) error
	FromAddress() post.Address
}

Sender sends emails

architecture: Service

type Service

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

Service sends template-backed email messages through SMTP

architecture: Service

func New

func New(log *zap.Logger, sender Sender, templatePath string) (*Service, error)

New creates new service.

func (*Service) Close added in v0.12.0

func (service *Service) Close() error

Close closes and waits for any pending actions.

func (*Service) Send

func (service *Service) Send(ctx context.Context, msg *post.Message) (err error)

Send is generalized method for sending custom email message.

func (*Service) SendRendered

func (service *Service) SendRendered(ctx context.Context, to []post.Address, msg Message) (err error)

SendRendered renders content from htmltemplate and texttemplate templates then sends it.

func (*Service) SendRenderedAsync added in v0.12.0

func (service *Service) SendRenderedAsync(ctx context.Context, to []post.Address, msg Message)

SendRenderedAsync renders content from htmltemplate and texttemplate templates then sends it asynchronously.

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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