mailer

package module
v0.0.0-...-c86c12d Latest Latest
Warning

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

Go to latest
Published: Oct 17, 2023 License: MIT Imports: 12 Imported by: 1

README

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Attachment

type Attachment struct {
	Filename string
	Data     []byte
	Inline   bool
}

Attachment represents an email attachment

type Email

type Email struct {
	To, Cc, Bcc                []string
	ToNames, CcNames, BccNames []string
	FromName, From             string
	ReplyToName, ReplyTo       string
	Subject                    string
	Attachments                []Attachment

	TextBody string
	HTMLBody string
}

Email all the things. The ToNames and friends are parallel arrays and must be 0-length or the same length as their counterpart. To omit a name for a user at an index in To simply use an empty string at that index in ToNames.

type Mailer

type Mailer interface {
	Send(ctx context.Context, email Email) (provider, msdID string, err error)
}

Mailer sends emails

type MultiMailer

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

MultiMailer takes multiple mailers and sends with them in sucession This is to be used for failovers

func NewMultiMailer

func NewMultiMailer(mailers ...Mailer) (*MultiMailer, error)

NewMultiMailer creates a new instance of a MultiMailer from a bunch of other mailers

func (MultiMailer) Send

func (m MultiMailer) Send(ctx context.Context, email Email) (string, string, error)

Send satisfies the Mailer interface. If an error is returned from this, it means ALL the mailers failed and the error will be a combination of all the errors received from every component mailer However, if any Mailer is successful, it will supress the errors from the previous ones

type SMTP

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

SMTP is an instance of the SMTP mailer

func NewSMTP

func NewSMTP(name, host string, port int, auth smtp.Auth) *SMTP

NewSMTP creates an instance of the SMTP mailer host (string): SMTP host port (int): SMTP port username (string): SMTP username password (string): SMTP password

func (*SMTP) Send

func (s *SMTP) Send(ctx context.Context, email Email) (string, string, error)

Send satisfies the mailer interface

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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