mbox

package module
v0.0.0-...-183f307 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: May 9, 2017 License: ISC Imports: 7 Imported by: 2

README

# go-mbox

## Introduction
`mbox` is a Go library to parse mbox files. It currently supports the mboxrd
format used for example for Google Mail exports.

## Library
The basic use case is to open a mailbox file and read its messages. The
following code does not include error handling.

```go
mbox, _ := mbox.Open(path, mbox.Mboxrd)

for {
    msg, _ := mbox.Read()
    if msg == nil {
        break
    }

    fmt.Printf("%s\n", msg.Id)
}

mbox.Close()
```

## mbox command
The `mbox` directory contains a tool to work with mbox files. Commands and
options can be displayed with `mbox -h`.

## Contact
If you have an idea or a question, email me at <[email protected]>.

Documentation

Index

Constants

View Source
const HeaderDateFormat = "Mon Jan 02 15:04:05 -0700 2006"

Variables

View Source
var FromLineRegexp = regexp.MustCompile("^>+From ")

Functions

func ParseMessagePrefix

func ParseMessagePrefix(data []byte) (id string, date time.Time, err error)

func UnescapeMessageData

func UnescapeMessageData(data []byte) []byte

Types

type Format

type Format string
const (
	Mboxrd Format = "mboxrd"
)

func (*Format) Parse

func (f *Format) Parse(s string) error

type Mbox

type Mbox struct {
	Format Format
	// contains filtered or unexported fields
}

func Open

func Open(path string, format Format) (*Mbox, error)

func (*Mbox) Close

func (mbox *Mbox) Close()

func (*Mbox) Read

func (mbox *Mbox) Read() (*Message, error)

type Message

type Message struct {
	Id   string
	Date time.Time
	Data []byte
}

func NewMessage

func NewMessage(id string, date time.Time, data []byte) *Message

Directories

Path Synopsis

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL