email

package
v3.11.0-rc1 Latest Latest
Warning

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

Go to latest
Published: Jan 25, 2021 License: Apache-2.0 Imports: 9 Imported by: 0

Documentation

Overview

Package email provides an interface to send messages over email.

Example
Output:

Index

Examples

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Config

type Config struct {
	SenderName    string `name:"sender-name" description:"The name of the sender"`
	SenderAddress string `name:"sender-address" description:"The address of the sender"`
	Provider      string `name:"provider" description:"Email provider to use"`
	Network       struct {
		Name              string `name:"name" description:"The name of the network"`
		IdentityServerURL string `name:"identity-server-url" description:"The URL of the Identity Server"`
		ConsoleURL        string `name:"console-url" description:"The URL of the Console"`
	} `name:"network" description:"The network of the sender"`
}

Config for sending emails

type Message

type Message struct {
	TemplateName string

	RecipientName    string
	RecipientAddress string

	Subject  string
	HTMLBody string
	TextBody string
}

Message for sending over email.

type MessageData

type MessageData interface {
	TemplateName() string
	Recipient() (name, address string)
	DefaultTemplates() (subject, html, text string)
}

MessageData interface contains everything we need to create an email.Message. The DefaultTemplates should be able to execute using the MessageData itself.

type MessageTemplate

type MessageTemplate struct {
	Name            string
	SubjectTemplate *template.Template
	HTMLTemplate    *template.Template
	TextTemplate    *template.Template
}

MessageTemplate is the template for an email message.

func (MessageTemplate) Execute

func (m MessageTemplate) Execute(data interface{}) (*Message, error)

Execute the message template, rendering it into a Message.

type Sender

type Sender interface {
	Send(message *Message) error
}

Sender is the interface for sending messages over email.

type TemplateRegistry

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

TemplateRegistry contains multiple email templates, identified by name.

func NewTemplateRegistry

func NewTemplateRegistry(fetcher fetch.Interface, includes ...string) (*TemplateRegistry, error)

NewTemplateRegistry returns a new template registry that uses the given fetcher.

func (*TemplateRegistry) Render

func (r *TemplateRegistry) Render(data MessageData) (*Message, error)

Render message template data into a message.

Directories

Path Synopsis
Package mock provides a test email provider that is used in tests.
Package mock provides a test email provider that is used in tests.
Package sendgrid provides the implementation of an email sender using SendGrid.
Package sendgrid provides the implementation of an email sender using SendGrid.

Jump to

Keyboard shortcuts

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