email

package
v0.2.1 Latest Latest
Warning

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

Go to latest
Published: May 9, 2025 License: MIT Imports: 5 Imported by: 0

Documentation

Overview

Package email provides an interface for plugins and application code to send email. [Gomail](gopkg.in/gomail.v2) is used with SMTP as the default.

SMTP can be configured using global configuration, either as ENV or from a configuration file.

|---------------------|---------------------| | Env | JSON | | --------------------|---------------------| | EMAIL_FROM | email.from | | EMAIL_SMTP_HOST | email.smtp.host | | EMAIL_SMTP_PORT | email.smtp.port | | EMAIL_SMTP_USERNAME | email.smtp.username | | EMAIL_SMTP_PASSWORD | email.smtp.password | |---------------------|---------------------|

Index

Constants

View Source
const PluginName = "email"

Constant name for identifying the email plugin.

Variables

This section is empty.

Functions

This section is empty.

Types

type EmailOption

type EmailOption func(*EmailPlugin)

EmailOptions customize the configuration of the email plugin.

func WithFrom

func WithFrom(from string) EmailOption

WithFrom configures the default from address.

func WithSMTP

func WithSMTP(host string, port int, username, password string) EmailOption

WithSMTP configures the SMTP server to use.

type EmailPlugin

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

EmailPlugin exposes the ability to send emails.

func Plugin

func Plugin(opts ...EmailOption) *EmailPlugin

Plugin returns a new EmailPlugin.

func (*EmailPlugin) Init

func (p *EmailPlugin) Init(ctx context.Context, r *prefab.Registry) error

From prefab.InitializablePlugin.

func (*EmailPlugin) Name

func (p *EmailPlugin) Name() string

From prefab.Plugin.

func (*EmailPlugin) Send

func (p *EmailPlugin) Send(ctx context.Context, msg *gomail.Message) error

Send an email. TODO: Switch to daemon mode per example here: https://pkg.go.dev/gopkg.in/gomail.v2#example-package-Daemon

Jump to

Keyboard shortcuts

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