Documentation ¶
Overview ¶
Package email includes helpers for sending SMTP messages.
Index ¶
- Constants
- type Message
- type MessageOption
- func OptBCC(bcc ...string) MessageOption
- func OptCC(cc ...string) MessageOption
- func OptFrom(from string) MessageOption
- func OptHTMLBody(htmlBody string) MessageOption
- func OptSubject(subject string) MessageOption
- func OptTextBody(textBody string) MessageOption
- func OptTo(to ...string) MessageOption
- type MockSender
- type SMTPPlainAuth
- type SMTPSender
- type Sender
Constants ¶
const ( ErrMessageFieldUnset ex.Class = "email; message required field unset" ErrMessageFieldNewlines ex.Class = "email; message field contains newlines" )
Errors
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Message ¶
type Message struct { From string `json:"from" yaml:"from"` To []string `json:"to" yaml:"to"` CC []string `json:"cc" yaml:"cc"` BCC []string `json:"bcc" yaml:"bcc"` Subject string `json:"subject" yaml:"subject"` TextBody string `json:"textBody" yaml:"textBody"` HTMLBody string `json:"htmlBody" yaml:"htmlBody"` }
Message is a message to send via. ses.
func ApplyMessageOptions ¶
func ApplyMessageOptions(m Message, options ...MessageOption) Message
ApplyMessageOptions applies options to a message and returns the mutated copy.
func MergeMessages ¶
MergeMessages merges a given set of messages, such that messages that appear last override the options in the output message provided those fields are set.
If message A has just the `To` field set, and message B has just the `Subject`field set, and message C also has the `To` field set, the result of:
MergeMessages(a,b,c)
Will be `To` of C, and `Subject` of B, with C overwriting the `To` of A.
type MessageOption ¶
type MessageOption func(m *Message)
MessageOption is a mutator for messages.
func OptHTMLBody ¶
func OptHTMLBody(htmlBody string) MessageOption
OptHTMLBody sets the html body for a message.
func OptSubject ¶
func OptSubject(subject string) MessageOption
OptSubject sets the subject for a message.
func OptTextBody ¶
func OptTextBody(textBody string) MessageOption
OptTextBody sets the text body for a message.
type SMTPPlainAuth ¶
type SMTPPlainAuth struct { Identity string `json:"identity" yaml:"identity"` Username string `json:"username" yaml:"username" env:"SMTP_USERNAME"` Password string `json:"password" yaml:"password" env:"SMTP_PASSWORD"` }
SMTPPlainAuth is a auth set for smtp.
func (SMTPPlainAuth) IsZero ¶
func (spa SMTPPlainAuth) IsZero() bool
IsZero returns if the plain auth is unset.
type SMTPSender ¶
type SMTPSender struct { LocalName string `json:"localname" yaml:"localname"` Host string `json:"host" yaml:"host" env:"SMTP_HOST"` Port string `json:"port" yaml:"port" env:"SMTP_PORT"` PlainAuth SMTPPlainAuth `json:"plainAuth" yaml:"plainAuth"` }
SMTPSender is a sender for emails over smtp.
func (SMTPSender) IsZero ¶
func (s SMTPSender) IsZero() bool
IsZero returns if the smtp sender is set or not.
func (SMTPSender) LocalNameOrDefault ¶
func (s SMTPSender) LocalNameOrDefault() string
LocalNameOrDefault returns a property or a default.
func (SMTPSender) PortOrDefault ¶
func (s SMTPSender) PortOrDefault() string
PortOrDefault returns a property or a default.