mailer

package module
v0.0.0-...-ed391f9 Latest Latest
Warning

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

Go to latest
Published: Aug 20, 2023 License: MIT Imports: 15 Imported by: 0

README

Mailer

go get -u github.com/rumorshub/mailer

License

Distributed under MIT License, please see license file within the code for more details.

Documentation

Index

Constants

View Source
const (
	PluginName = "mailer"
)

Variables

This section is empty.

Functions

func PseudorandomString

func PseudorandomString(length int) string

func PseudorandomStringWithAlphabet

func PseudorandomStringWithAlphabet(length int, alphabet string) string

Types

type AddressConfig

type AddressConfig struct {
	Name    string `mapstructure:"name" json:"name,omitempty" bson:"name,omitempty"`          // Proper name; may be empty.
	Address string `mapstructure:"address" json:"address,omitempty" bson:"address,omitempty"` // user@domain
}

type Configurer

type Configurer interface {
	Has(name string) bool
	UnmarshalKey(name string, out interface{}) error
}

type Mailer

type Mailer interface {
	// Send sends an email with the provided Message.
	Send(message *Message) error
}

Mailer defines a base mail client interface.

type Message

type Message struct {
	From        mail.Address
	To          []mail.Address
	Bcc         []mail.Address
	Cc          []mail.Address
	Subject     string
	HTML        string
	Text        string
	Headers     map[string]string
	Attachments map[string]io.Reader
}

Message defines a generic email message struct.

type Plugin

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

func (*Plugin) Init

func (p *Plugin) Init(cfg Configurer) error

func (*Plugin) Mailer

func (p *Plugin) Mailer() Mailer

func (*Plugin) Name

func (p *Plugin) Name() string

func (*Plugin) Provides

func (p *Plugin) Provides() []*dep.Out

type SendMail

type SendMail struct {
	CmdPath string `mapstructure:"cmd_path" json:"cmd_path,omitempty" bson:"cmd_path,omitempty"` // sendmail cmd path
}

SendMail implements mailer.Mailer interface and defines a mail client that sends emails via the "sendmail" *nix command.

This client is usually recommended only for development and testing.

func (SendMail) Send

func (c SendMail) Send(m *Message) error

Send implements `mailer.Mailer` interface.

type SmtpAuth

type SmtpAuth string
const (
	SmtpAuthPlain SmtpAuth = "PLAIN"
	SmtpAuthLogin SmtpAuth = "LOGIN"
)

type SmtpClient

type SmtpClient struct {
	Host       string        `mapstructure:"host" json:"host,omitempty" bson:"host,omitempty"`
	Port       int           `mapstructure:"port" json:"port,omitempty" bson:"port,omitempty"`
	Username   string        `mapstructure:"username" json:"username,omitempty" bson:"username,omitempty"`
	Password   string        `mapstructure:"password" json:"password,omitempty" bson:"password,omitempty"`
	Tls        bool          `mapstructure:"tls" json:"tls,omitempty" bson:"tls,omitempty"`
	AuthMethod SmtpAuth      `mapstructure:"auth" json:"auth_method,omitempty" bson:"auth_method,omitempty"` // default to "PLAIN"
	From       AddressConfig `mapstructure:"from" json:"from,omitempty" bson:"from,omitempty"`
}

SmtpClient defines a SMTP mail client structure that implements `mailer.Mailer` interface.

func (SmtpClient) Send

func (c SmtpClient) Send(m *Message) error

Send implements `mailer.Mailer` interface.

Jump to

Keyboard shortcuts

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