communication

package
v0.0.0-...-b1b50a1 Latest Latest
Warning

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

Go to latest
Published: Sep 17, 2020 License: MIT Imports: 5 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type EmailConfiguration

type EmailConfiguration struct {
	Username string
	Password string
	Host     string
	Port     int
}

EmailConfiguration configures an email sender account.

There is no default email configuration so email credentials are required.

func (EmailConfiguration) Send

func (emailCfg EmailConfiguration) Send(emailMsg EmailMessage) error

Send sends the provided message given an email configuration

type EmailMessage

type EmailMessage struct {
	// email sender is not necessarily the same account used in the email configuration, e.g.: no-reply account
	From    string
	To      []string
	Subject string
	Body    string
	// text/plain or text/html
	ContentType string
	// Additional headers out of "From", "To", "Subject"
	AdditionalHeaders map[string]string
}

EmailMessage harmonises email message format which will be sent by an EmailConfiguration

Jan-2020: Multipart emails are not supported

func NewEmailHTMLMessage

func NewEmailHTMLMessage(from string, to []string, subject string, templatePath string, emailData interface{}) (EmailMessage, error)

NewEmailHTMLMessage generate a HTML EmailMessage from a template path

func NewEmailTextMessage

func NewEmailTextMessage(from string, to []string, subject string, message string) EmailMessage

NewEmailTextMessage generate a basic text EmailMessage

type EmailSender

type EmailSender interface {
	Send(emailMsg EmailMessage) error
}

EmailSender qualifies an entity which is capable to send an `EmailMessage`

A given email sender does not have to cover all email format (HTML, text)

Jump to

Keyboard shortcuts

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