Documentation
¶
Index ¶
- type Attachment
- type AttachmentReference
- type AttachmentResolver
- type Mailer
- func (m *Mailer) Send(msg *Message) error
- func (m *Mailer) SendContext(ctx context.Context, msg *Message) error
- func (m *Mailer) SendJSON(data []byte) error
- func (m *Mailer) SendJSONContext(ctx context.Context, data []byte) error
- func (m *Mailer) SendJSONWithResolver(ctx context.Context, data []byte, resolver AttachmentResolver) error
- func (m *Mailer) SendWithResolver(ctx context.Context, msg *Message, resolver AttachmentResolver) error
- type Message
- type Recipient
- type ResolvedAttachment
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Attachment ¶
type Attachment struct {
Name string `json:"name,omitempty"`
Path string `json:"path,omitempty"`
Content []byte `json:"content,omitempty"`
Reference *AttachmentReference `json:"reference,omitempty"`
}
Attachment describes content to attach. Content takes precedence over Path, and Path takes precedence over Reference. SaveJSON embeds path-backed content but preserves external references without resolving them.
type AttachmentReference ¶ added in v0.2.0
type AttachmentReference struct {
Store string `json:"store"`
Key string `json:"key"`
Version string `json:"version,omitempty"`
Size int64 `json:"size,omitempty"`
Digest string `json:"digest,omitempty"`
ContentType string `json:"content_type,omitempty"`
}
AttachmentReference identifies attachment content in an external store. Store is a logical name interpreted by an AttachmentResolver; the reference never contains storage credentials.
type AttachmentResolver ¶ added in v0.2.0
type AttachmentResolver interface {
Open(context.Context, AttachmentReference) (ResolvedAttachment, error)
}
AttachmentResolver opens externally stored attachment content. Upload and lifecycle management remain the caller's responsibility.
type Mailer ¶
type Mailer struct {
SmtpHost string
SmtpPort int
SmtpUsername string
SmtpPassword string
SmtpSenderAddress string
SmtpSenderName string
SmtpTLSPortPolicy string
SmtpTimeout time.Duration
}
func (*Mailer) SendContext ¶ added in v0.2.0
func (*Mailer) SendJSONContext ¶ added in v0.2.0
func (*Mailer) SendJSONWithResolver ¶ added in v0.2.0
func (m *Mailer) SendJSONWithResolver(ctx context.Context, data []byte, resolver AttachmentResolver) error
SendJSONWithResolver decodes and sends a message, resolving external attachments with resolver.
func (*Mailer) SendWithResolver ¶ added in v0.2.0
func (m *Mailer) SendWithResolver(ctx context.Context, msg *Message, resolver AttachmentResolver) error
SendWithResolver sends a message, resolving external attachments with resolver. The resolver must remain valid for the duration of the call.
type Message ¶
type Message struct {
To []*Recipient `json:"to,omitempty"`
Cc []*Recipient `json:"cc,omitempty"`
Bcc []*Recipient `json:"bcc,omitempty"`
From *Recipient `json:"from,omitempty"`
Subject string `json:"subject,omitempty"`
Content string `json:"content,omitempty"`
HTML string `json:"html,omitempty"`
Attachments []*Attachment `json:"attachments,omitempty"`
}
type Recipient ¶
func ParseAddress ¶
type ResolvedAttachment ¶ added in v0.2.0
type ResolvedAttachment struct {
Reader io.ReadCloser
Size int64
ContentType string
}
ResolvedAttachment is content opened by an AttachmentResolver. Reader is closed by the mailer after sending. Seekable readers avoid in-memory buffering in the underlying mail package.