Documentation
¶
Overview ¶
Package mail provides immutable, bounded MIME messages and a transport- neutral sender contract.
Index ¶
Examples ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type AttachmentSpec ¶
AttachmentSpec describes one ordinary MIME attachment.
type Message ¶
type Message struct {
// contains filtered or unexported fields
}
Message is an immutable serialized MIME message plus its SMTP envelope.
Example ¶
message, err := NewMessage(MessageSpec{
ID: "order-41@example.com",
Date: mailTestDate,
From: "Orders <orders@example.com>",
To: []string{"customer@example.com"},
Subject: "Order 41 is ready",
TextBody: "Your order is ready.",
})
if err != nil {
panic(err)
}
fmt.Println(message.ID(), message.Recipients())
Output: order-41@example.com [customer@example.com]
func NewMessage ¶
func NewMessage(spec MessageSpec) (Message, error)
NewMessage validates, copies, and deterministically serializes one message.
func (Message) EnvelopeFrom ¶
EnvelopeFrom returns the normalized SMTP envelope sender.
func (Message) Recipients ¶
Recipients returns de-duplicated To, Cc, and Bcc envelope recipients in that stable order.
type MessageSpec ¶
type MessageSpec struct {
ID string
Date time.Time
From string
To []string
Cc []string
Bcc []string
ReplyTo string
Subject string
TextBody string
HTMLBody string
Attachments []AttachmentSpec
}
MessageSpec is the inspectable input to NewMessage. Date and ID are caller-owned so serialization has no hidden clock, hostname, or randomness.
Click to show internal directories.
Click to hide internal directories.