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

Basic MIME parsing is now integrated, this closes #1

This commit is contained in:
James Hillyerd
2012-10-17 21:10:02 -07:00
parent e76fad1523
commit 0efb28ef38
4 changed files with 68 additions and 52 deletions

View File

@@ -174,8 +174,10 @@ func (m *Message) ReadHeader() (msg *mail.Message, err error) {
return msg, err
}
// ReadBody opens the .raw portion of a Message and returns a standard Go mail.Message object
func (m *Message) ReadBody() (msg *mail.Message, body *string, err error) {
// ReadBody opens the .raw portion of a Message and returns a MIMEBody object, along
// with a free mail.Message containing the Headers, since we had to make one of those
// anyway.
func (m *Message) ReadBody() (msg *mail.Message, body *MIMEBody, err error) {
file, err := os.Open(m.rawPath())
defer file.Close()
if err != nil {
@@ -186,12 +188,11 @@ func (m *Message) ReadBody() (msg *mail.Message, body *string, err error) {
if err != nil {
return nil, nil, err
}
bodyBytes, err := ioutil.ReadAll(reader)
mime, err := ParseMIMEBody(msg)
if err != nil {
return nil, nil, err
}
bodyString := string(bodyBytes)
return msg, &bodyString, err
return msg, mime, err
}
// ReadRaw opens the .raw portion of a Message and returns it as a string