mailer

package
v0.0.4 Latest Latest
Warning

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

Go to latest
Published: Dec 16, 2020 License: GPL-3.0 Imports: 14 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type EmailAttachment

type EmailAttachment struct {
	ContentType string `json:"content_type"`
	FileName    string `json:"filename"`
	Contents    []byte `json:"contents"`
}

EmailAttachment is a JSON structure for an email attachment in encoded job.

type EmailJob

type EmailJob struct {
	To          string            `json:"to"`
	Subject     string            `json:"subject"`
	Body        string            `json:"body"`
	Attachments []EmailAttachment `json:"attachments"`
}

EmailJob - the JSON structure for db.Email Job field.

type MailSender

type MailSender interface {
	Queue(msg EmailJob) error
}

MailSender - public interface for queuing emails to be sent.

type Mailer

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

Mailer manages background services for sending email. New emails are queued in queued until the processing coroutine saves them to the database in a batch. The processing routine also searches for new emails to send Implements MailSender

func NewMailer

func NewMailer(database db.Database, from string, dialer *mail.Dialer) *Mailer

NewMailer creates a new Mailer

func (*Mailer) Queue

func (m *Mailer) Queue(job EmailJob) error

Queue adds job to the queue so it can be persisted later. See MailSender.Queue

func (*Mailer) Start

func (m *Mailer) Start()

Start invokes the processing goroutine

func (*Mailer) Stop

func (m *Mailer) Stop()

Stop cancels the processing goroutine and waits for it to finish

Jump to

Keyboard shortcuts

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