1
0
mirror of https://github.com/jhillyerd/inbucket.git synced 2025-12-20 02:57:05 +00:00

Add a view source button to see raw text of message

This commit is contained in:
James Hillyerd
2012-10-13 14:37:11 -07:00
parent a0ab84abb5
commit eb363aa670
4 changed files with 44 additions and 1 deletions

View File

@@ -194,6 +194,22 @@ func (m *Message) ReadBody() (msg *mail.Message, body *string, err error) {
return msg, &bodyString, err
}
// ReadRaw opens the .raw portion of a Message and returns it as a string
func (m *Message) ReadRaw() (raw *string, err error) {
file, err := os.Open(m.rawPath())
defer file.Close()
if err != nil {
return nil, err
}
reader := bufio.NewReader(file)
bodyBytes, err := ioutil.ReadAll(reader)
if err != nil {
return nil, err
}
bodyString := string(bodyBytes)
return &bodyString, nil
}
// Append data to a newly opened Message, this will fail on a pre-existing Message and
// after Close() is called.
func (m *Message) Append(data []byte) error {