Documentation
¶
Index ¶
- func RegisterDriver(name string, factory func() (Mailer, error))
- func SetTemplatePath(path string)
- type Address
- type Attachment
- type MailConfig
- type MailFailed
- type MailSent
- type Mailer
- type Manager
- func (m *Manager) Broadcast(ctx context.Context, channels []string, msg *Message) error
- func (m *Manager) Channel(name string) Mailer
- func (m *Manager) ClearChannels()
- func (m *Manager) GetChannels() []string
- func (m *Manager) HasChannel(name string) bool
- func (m *Manager) RemoveChannel(name string)
- func (m *Manager) Send(ctx context.Context, channel string, msg *Message) error
- func (m *Manager) SetChannel(name string, mailer Mailer)
- func (m *Manager) SetEventDispatcher(fn func(event interface{}) error)
- type Message
- func (m *Message) AttachData(data []byte, name, contentType string) *Message
- func (m *Message) AttachFile(path string) (*Message, error)
- func (m *Message) BCC(email string, name ...string) *Message
- func (m *Message) Body(body string) *Message
- func (m *Message) CC(email string, name ...string) *Message
- func (m *Message) From(email string, name ...string) *Message
- func (m *Message) GetAttachments() []Attachment
- func (m *Message) GetBCC() []Address
- func (m *Message) GetCC() []Address
- func (m *Message) GetFrom() Address
- func (m *Message) GetHTMLBody() string
- func (m *Message) GetHeaders() map[string]string
- func (m *Message) GetPriority() Priority
- func (m *Message) GetReplyTo() []Address
- func (m *Message) GetSubject() string
- func (m *Message) GetTextBody() string
- func (m *Message) GetTo() []Address
- func (m *Message) HTMLBody(body string) *Message
- func (m *Message) Header(key, value string) *Message
- func (m *Message) Priority(priority Priority) *Message
- func (m *Message) ReplyTo(email string, name ...string) *Message
- func (m *Message) Subject(subject string) *Message
- func (m *Message) Template(name string, data interface{}) (*Message, error)
- func (m *Message) TextBody(body string) *Message
- func (m *Message) To(email string, name ...string) *Message
- type Priority
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func RegisterDriver ¶
RegisterDriver allows drivers to register themselves
func SetTemplatePath ¶ added in v0.8.0
func SetTemplatePath(path string)
SetTemplatePath configures the directory for email templates
Types ¶
type Address ¶
Address represents an email address
func NewAddress ¶ added in v0.9.2
NewAddress creates and validates an email address. Returns an error if the email format is invalid.
type Attachment ¶
Attachment represents an email attachment
type MailConfig ¶ added in v0.9.5
type MailConfig struct {
// Driver is the mail driver to use (e.g. "log", "postmark", "mailgun").
Driver string
}
MailConfig holds configuration for creating a mailer.
type MailFailed ¶ added in v0.8.0
type MailFailed struct {
Context context.Context
To []string
Subject string
Channel string
Error string
DurationMs int64
TraceID string
SpanID string
ParentID string
}
MailFailed is dispatched when an email fails to send
func (*MailFailed) Name ¶ added in v0.8.0
func (e *MailFailed) Name() string
Name returns the event name
type MailSent ¶ added in v0.8.0
type MailSent struct {
Context context.Context
To []string
Subject string
Channel string
DurationMs int64
TraceID string
SpanID string
ParentID string
}
MailSent is dispatched after an email is sent successfully
type Mailer ¶
Mailer interface that all mail drivers must implement
func NewMailer ¶ added in v0.9.5
func NewMailer(config MailConfig) (Mailer, error)
NewMailer creates a new Mailer from the given configuration. Drivers must be registered via RegisterDriver before calling this function.
type Manager ¶
type Manager struct {
// contains filtered or unexported fields
}
Manager manages multiple mail channels
func (*Manager) ClearChannels ¶
func (m *Manager) ClearChannels()
ClearChannels removes all channels
func (*Manager) GetChannels ¶
GetChannels returns all channel names
func (*Manager) HasChannel ¶
HasChannel checks if a channel exists
func (*Manager) RemoveChannel ¶
RemoveChannel removes a channel
func (*Manager) SetChannel ¶
SetChannel sets a specific mailer for a channel
func (*Manager) SetEventDispatcher ¶ added in v0.9.11
SetEventDispatcher sets the function used to dispatch events.
type Message ¶
type Message struct {
// contains filtered or unexported fields
}
Message represents an email message
func (*Message) AttachData ¶
AttachData attaches data from memory
func (*Message) AttachFile ¶
AttachFile attaches a file from the filesystem. Returns an error if the file cannot be read or the path contains traversal sequences.
func (*Message) GetAttachments ¶
func (m *Message) GetAttachments() []Attachment
GetAttachments returns the attachments
func (*Message) GetHTMLBody ¶
GetHTMLBody returns the HTML body
func (*Message) GetHeaders ¶
GetHeaders returns the custom headers
func (*Message) GetPriority ¶
GetPriority returns the priority
func (*Message) GetReplyTo ¶
GetReplyTo returns the reply-to addresses
func (*Message) GetTextBody ¶
GetTextBody returns the plain text body
func (*Message) Template ¶
Template renders a template with data and sets it as HTML body. Returns an error if the template name is invalid or template processing fails.
Directories
¶
| Path | Synopsis |
|---|---|
|
Package alldrivers imports all mail drivers to register them Import this package with _ to ensure all drivers are registered
|
Package alldrivers imports all mail drivers to register them Import this package with _ to ensure all drivers are registered |