Documentation ¶
Overview ¶
Package email provides an interface to send messages over email.
Index ¶
- func RegisterNotification(name string, builder *NotificationBuilder)
- func RegisterTemplate(tmpl *Template)
- func RegisteredNotifications() []string
- func RegisteredTemplates() []string
- type Config
- type FSTemplate
- type MapNotificationRegistry
- type MapTemplateRegistry
- type Message
- type NetworkConfig
- type NotificationBuilder
- type NotificationRegistry
- type NotificationTemplateData
- type NotificationTemplateDataBuilder
- type Sender
- type Template
- type TemplateData
- type TemplateDataBuilder
- type TemplateRegistry
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func RegisterNotification ¶ added in v3.19.2
func RegisterNotification(name string, builder *NotificationBuilder)
RegisterNotification registers an email notification on the default registry.
func RegisterTemplate ¶ added in v3.19.2
func RegisterTemplate(tmpl *Template)
RegisterTemplate registers a template on the default registry.
func RegisteredNotifications ¶ added in v3.19.2
func RegisteredNotifications() []string
RegisteredNotifications returns the names of the registered email notifications in the default registry.
func RegisteredTemplates ¶ added in v3.19.2
func RegisteredTemplates() []string
RegisteredTemplates returns the names of the registered templates in the default registry.
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 NetworkConfig `name:"network" description:"The network of the sender"` }
Config is the configuration for sending emails.
type FSTemplate ¶ added in v3.19.2
type FSTemplate struct { SubjectTemplate string HTMLTemplateBaseFile string HTMLTemplateFile string TextTemplateBaseFile string TextTemplateFile string IncludePatterns []string }
FSTemplate defines the template files to parse from the file system.
type MapNotificationRegistry ¶ added in v3.19.2
type MapNotificationRegistry map[string]*NotificationBuilder
MapNotificationRegistry is an email notification registry implementation.
func NewNotificationRegistry ¶ added in v3.19.2
func NewNotificationRegistry() MapNotificationRegistry
NewNotificationRegistry returns a new empty email notification registry.
func (MapNotificationRegistry) GetNotification ¶ added in v3.19.2
func (reg MapNotificationRegistry) GetNotification(_ context.Context, name string) *NotificationBuilder
GetNotification returns a registered email notification from the registry.
func (MapNotificationRegistry) RegisterNotification ¶ added in v3.19.2
func (reg MapNotificationRegistry) RegisterNotification(name string, builder *NotificationBuilder)
RegisterNotification registers an email notification.
func (MapNotificationRegistry) RegisteredNotifications ¶ added in v3.19.2
func (reg MapNotificationRegistry) RegisteredNotifications() []string
RegisteredNotifications returns a sorted list of the names of all registered email notifications.
type MapTemplateRegistry ¶ added in v3.19.2
MapTemplateRegistry is a template registry implementation.
func NewTemplateRegistry ¶
func NewTemplateRegistry() MapTemplateRegistry
NewTemplateRegistry returns a new empty template registry.
func (MapTemplateRegistry) GetTemplate ¶ added in v3.19.2
func (reg MapTemplateRegistry) GetTemplate(_ context.Context, name string) *Template
GetTemplate returns a registered template from the registry.
func (MapTemplateRegistry) RegisterTemplate ¶ added in v3.19.2
func (reg MapTemplateRegistry) RegisterTemplate(tmpl *Template)
RegisterTemplate registers a template.
func (MapTemplateRegistry) RegisteredTemplates ¶ added in v3.19.2
func (reg MapTemplateRegistry) RegisteredTemplates() []string
RegisteredTemplates returns a sorted list of the names of all registered templates.
type Message ¶
type Message struct { TemplateName string RecipientName string RecipientAddress string Subject string HTMLBody string TextBody string }
Message for sending over email.
type NetworkConfig ¶ added in v3.19.2
type NetworkConfig 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"` AssetsBaseURL string `name:"assets-base-url" description:"The base URL to the email assets"` BrandingBaseURL string `name:"branding-base-url" description:"The base URL to the email branding assets"` }
NetworkConfig is the configuration of the network that sends the emails. This configuration is used by email templates.
type NotificationBuilder ¶ added in v3.19.2
type NotificationBuilder struct { EmailTemplateName string DataBuilder NotificationTemplateDataBuilder }
NotificationBuilder is used to build notifications.
func GetNotification ¶ added in v3.19.2
func GetNotification(ctx context.Context, name string) *NotificationBuilder
GetNotification returns a registered email notification from the registry in the context (if available), otherwise falling back to the default registry.
type NotificationRegistry ¶ added in v3.19.2
type NotificationRegistry interface { RegisteredNotifications() []string GetNotification(ctx context.Context, name string) *NotificationBuilder }
NotificationRegistry keeps track of email notifications.
type NotificationTemplateData ¶ added in v3.19.2
type NotificationTemplateData interface { TemplateData Notification() *ttnpb.Notification ConsoleURL() string Receivers() string }
NotificationTemplateData extends TemplateData for notifications.
func NewNotificationTemplateData ¶ added in v3.19.2
func NewNotificationTemplateData(data TemplateData, notification *ttnpb.Notification) NotificationTemplateData
NewNotificationTemplateData returns new notification template data.
type NotificationTemplateDataBuilder ¶ added in v3.19.2
type NotificationTemplateDataBuilder func(context.Context, NotificationTemplateData) (NotificationTemplateData, error)
NotificationTemplateDataBuilder is used to extend NotificationTemplateData.
type Template ¶ added in v3.19.2
type Template struct { Name string SubjectTemplate *template.Template HTMLTemplate *template.Template TextTemplate *template.Template }
Template is the template for an email message.
func GetTemplate ¶ added in v3.19.2
GetTemplate returns a registered template from the registry in the context (if available), otherwise falling back to the default registry.
func NewTemplateFS ¶ added in v3.19.2
NewTemplateFS parses a new email template by reading files on fsys.
type TemplateData ¶ added in v3.19.2
type TemplateData interface { Network() *NetworkConfig ConsoleURL() string Receiver() *ttnpb.User ReceiverName() string }
TemplateData is the minimal interface Execute needs to render an email template.
func NewTemplateData ¶ added in v3.19.2
func NewTemplateData(networkConfig *NetworkConfig, receiver *ttnpb.User) TemplateData
NewTemplateData returns new template data.
type TemplateDataBuilder ¶ added in v3.19.2
type TemplateDataBuilder func(context.Context, TemplateData) (TemplateData, error)
TemplateDataBuilder is used to extend TemplateData.
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. |