emailer

package
v0.0.0-...-a7c217f Latest Latest
Warning

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

Go to latest
Published: Apr 30, 2024 License: AGPL-3.0 Imports: 6 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	// ErrMissingContent is used when sending an email without parts
	ErrMissingContent = errors.New("emailer: missing content")
	// ErrMissingSubject is used when sending an email without subject
	ErrMissingSubject = errors.New("emailer: missing subject")
	// ErrMissingTemplate is used when sending an email without a template name
	// or template values
	ErrMissingTemplate = errors.New("emailer: missing template")
)

Functions

func SendEmail deprecated

func SendEmail(inst *instance.Instance, cmd *TransactionalEmailCmd) error

SendEmail send a mail to the instance owner.

Deprecated: use EmailerService.SendEmail instead.

Types

type CampaignEmailCmd

type CampaignEmailCmd struct {
	Parts   []mail.Part
	Subject string
}

CampaignEmailCmd contains the information required to send a campaign email to the instance owner.

type Emailer

type Emailer interface {
	SendEmail(inst *instance.Instance, cmd *TransactionalEmailCmd) error
	SendPendingEmail(inst *instance.Instance, cmd *TransactionalEmailCmd) error
	SendCampaignEmail(inst *instance.Instance, cmd *CampaignEmailCmd) error
}

Emailer allows to send a pre-formatted email to an instance owner.

This interface has several implementations: - EmailerService sending email via an async job - Mock with a mock implementation

type EmailerService

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

EmailerService allows to send emails.

This broker send the emails via anrasynchronous job.

func Init

func Init() *EmailerService

Init the emailer package by setting up a service based on the global config and setup the global functions.

func NewEmailerService

func NewEmailerService(jobBroker job.Broker) *EmailerService

NewEmailerService instantiates an EmailerService.

func (*EmailerService) SendCampaignEmail

func (s *EmailerService) SendCampaignEmail(inst *instance.Instance, cmd *CampaignEmailCmd) error

SendCampaignEmail sends a campaign email to the instance owner with the given cmd content via the dedicated campaign mail server.

func (*EmailerService) SendEmail

func (s *EmailerService) SendEmail(inst *instance.Instance, cmd *TransactionalEmailCmd) error

SendEmail sends a mail to the instance owner.

func (*EmailerService) SendPendingEmail

func (s *EmailerService) SendPendingEmail(inst *instance.Instance, cmd *TransactionalEmailCmd) error

SendPendingEmail sends a mail to the instance owner on their new pending email address. It is used to confirm that they can receive emails on the new email address.

type Mock

type Mock struct {
	mock.Mock
}

Mock implementation of Emailer.

func NewMock

func NewMock(t *testing.T) *Mock

NewMock instantiates a new Mock.

func (*Mock) SendCampaignEmail

func (m *Mock) SendCampaignEmail(inst *instance.Instance, cmd *CampaignEmailCmd) error

SendCampaignEmail mock method

func (*Mock) SendEmail

func (m *Mock) SendEmail(inst *instance.Instance, cmd *TransactionalEmailCmd) error

SendEmail mock method.

func (*Mock) SendPendingEmail

func (m *Mock) SendPendingEmail(inst *instance.Instance, cmd *TransactionalEmailCmd) error

SendPendingEmail mock method.

type TransactionalEmailCmd

type TransactionalEmailCmd struct {
	TemplateName   string
	TemplateValues map[string]interface{}
}

TransactionalEmailCmd contains the information to send a transactional email to the instance owner.

Jump to

Keyboard shortcuts

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