mailer

package
v1.2.3 Latest Latest
Warning

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

Go to latest
Published: Jan 17, 2024 License: MIT Imports: 12 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	ConfigBuilder = runtime.NewConfigSchemaBuilder(addToSchema)
	AddToSchema   = ConfigBuilder.AddToSchema
)
View Source
var AccountSpec = conf.SectionSpec{
	{
		Name:        "Host",
		Required:    true,
		Description: "The hostname of the outgoing mail server",
		Type:        conf.StringType,
	},
	{
		Name:        "Port",
		Default:     "587",
		Description: "The port of the outgoing mail server",
		Type:        conf.IntType,
	},
	{
		Name:        "Username",
		Description: "The username for the SMPT server authentication.",
		Type:        conf.StringType,
	},
	{
		Name:        "Password",
		Description: "The password of the user.",
		Type:        conf.StringType,
		Annotations: new(conf.Annotation).With(
			conf.SecretValue(),
		),
	},
	{
		Name:        "From",
		Description: "The default sender to use",
		Type:        conf.StringType,
	},
	{
		Name:        "AllowInsecure",
		Type:        conf.BoolType,
		Description: "If set to true, the certificate of the upstream SMTP server is not verified.",
		Default:     "no",
	},
	{
		Name:        "UseSSL",
		Type:        conf.BoolType,
		Description: "Whether or not SSL should be enabled or disabled. Leave empty for the default",
	},
}

AccountSpec is defines the configuration stanzas for a mailer Account.

View Source
var MessageSpec = conf.SectionSpec{
	{
		Name:        "From",
		Type:        conf.StringType,
		Description: "The sender email to use.",
	},
	{
		Name:        "To",
		Type:        conf.StringSliceType,
		Description: "Receipients for the message.",
		Required:    true,
	},
	{
		Name:        "Cc",
		Type:        conf.StringSliceType,
		Description: "Additional Cc receipients for the message. E-Mail addresses will be exposed to all receipients.",
	},
	{
		Name:        "Bcc",
		Type:        conf.StringSliceType,
		Description: "Additional blind Cc receipients for the message.",
	},
	{
		Name:        "Subject",
		Type:        conf.StringType,
		Description: "The subject of the email message.",
		Required:    true,
	},
	{
		Name:    "BodyContentType",
		Type:    conf.StringType,
		Default: "text/plain",
	},
	{
		Name:        "Body",
		Description: "The email body template. If used BodyFile= must be empty",
		Type:        conf.StringType,
		Annotations: new(conf.Annotation).With(
			runtime.StringFormat("text/plain"),
		),
	},
}

Functions

func AddTriggerType

func AddTriggerType(reg *trigger.Registry) error

AddTriggerType registers a "SendMail" trigger on reg using typeName.

Types

type Account

type Account struct {
	// Host should holds the SMPT host name the mailer should
	// use to send mails.
	Host string
	// Port should holds the SMTP port the host is listening on.
	Port int
	// Username required for authentication.
	Username string
	// Password required for authentication.
	Password string
	// From defines the default sender to use for this account.
	From string
	// AllowInsecure can be set to true to disable TLS certificate
	// verification.
	AllowInsecure bool
	// UseSSL can be set to either true or false to force SSL to be enabled
	// or disabled. If not configured, SSL will be used for the default
	// SSL port.
	UseSSL *bool
}

type Mailer

type Mailer interface {
	Send(ctx context.Context, msg Message, context interface{}) error
}

func New

func New(account Account) (Mailer, error)

New returns a new mailer that sends mail through account.

type Message

type Message struct {
	From            string
	To              []string
	Cc              []string
	Bcc             []string
	Subject         string // text/template
	BodyContentType string
	Body            string // text/template
}

Jump to

Keyboard shortcuts

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