Documentation ¶
Overview ¶
Package mbox parses and formats the mbox file format.
As the mbox file format is not standardized this package expects the least common denominator, the so called mboxo format.
Index ¶
Examples ¶
Constants ¶
This section is empty.
Variables ¶
View Source
var ErrInvalidFormat = errors.New("invalid mbox format")
ErrInvalidFormat is the error returned by the NextMessage method of Reader if its content is malformed in a way that it is not possible to extract a message.
Functions ¶
This section is empty.
Types ¶
type Reader ¶ added in v1.0.0
type Reader struct {
// contains filtered or unexported fields
}
Reader reads an mbox archive.
Example ¶
r := strings.NewReader(`From herp.derp@example.com Thu Jan 1 00:00:01 2015 From: herp.derp@example.com (Herp Derp) Date: Thu, 01 Jan 2015 00:00:01 +0100 Subject: Test This is a simple test. CU. From derp.herp@example.com Thu Jan 1 00:00:01 2015 From: derp.herp@example.com (Derp Herp) Date: Thu, 02 Jan 2015 00:00:01 +0100 Subject: Another test This is another simple test. Bye. `) mr := NewReader(r) for { r, err := mr.NextMessage() if err == io.EOF { break } else if err != nil { fmt.Print("Oops, something went wrong!", err) return } msg, err := mail.ReadMessage(r) if err != nil { fmt.Print("Oops, something went wrong!", err) return } fmt.Printf("Message from %v\n", msg.Header.Get("From")) }
Output: Message from herp.derp@example.com (Herp Derp) Message from derp.herp@example.com (Derp Herp)
Click to show internal directories.
Click to hide internal directories.