1
0
mirror of https://github.com/jhillyerd/inbucket.git synced 2025-12-17 17:47:03 +00:00

Hide envelope, use Part.Content for #85

This commit is contained in:
James Hillyerd
2018-03-20 17:55:43 -07:00
parent 6d250a47b4
commit e7a86bd8f8
5 changed files with 65 additions and 36 deletions

View File

@@ -5,6 +5,7 @@ import (
"io"
"io/ioutil"
"net/mail"
"net/textproto"
"time"
"github.com/jhillyerd/enmime"
@@ -25,7 +26,40 @@ type Metadata struct {
// Message holds both the metadata and content of a message.
type Message struct {
Metadata
Envelope *enmime.Envelope
env *enmime.Envelope
}
// New constructs a new Message
func New(m Metadata, e *enmime.Envelope) *Message {
return &Message{
Metadata: m,
env: e,
}
}
// Attachments returns the MIME attachments for the message.
func (m *Message) Attachments() []*enmime.Part {
return m.env.Attachments
}
// Header returns the header map for this message.
func (m *Message) Header() textproto.MIMEHeader {
return m.env.Root.Header
}
// HTML returns the HTML body of the message.
func (m *Message) HTML() string {
return m.env.HTML
}
// MIMEErrors returns MIME parsing errors and warnings.
func (m *Message) MIMEErrors() []*enmime.Error {
return m.env.Errors
}
// Text returns the plain text body of the message.
func (m *Message) Text() string {
return m.env.Text
}
// Delivery is used to add a message to storage.