mbox

package
v1.1.5 Latest Latest
Warning

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

Go to latest
Published: Nov 18, 2026 License: Apache-2.0 Imports: 7 Imported by: 1 module, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

Documentation

Overview

Package mbox reads mailboxes in the mbox format, such as Eudora's .mbx files, and Thunderbird's and Unix mail's mailboxes, which are messages, each after a line which starts with From, the sender, and the date it was received, a message at a time

Index

Constants

View Source
const (
	// ContentType is the content type of a mailbox
	ContentType = "application/mbox"

	// MaxMessageSize is the most of a message which is read
	MaxMessageSize = 32 << 20
)

Variables

This section is empty.

Functions

This section is empty.

Types

type Message

type Message struct {
	// The sender of the message, from its From line, which is empty when it
	// isn't known, as Eudora writes it, ???@???
	Sender string

	// When the message was received, from its From line, in UTC, as the
	// time zone isn't known
	Date time.Time

	// The message, with line feeds, and the lines which start with From,
	// which are escaped as >From, as they are. A message which is longer
	// than MaxMessageSize is cut short.
	Data []byte
}

Message is a message in a mailbox

type Reader

type Reader struct {
	// contains filtered or unexported fields
}

Reader reads the messages of a mailbox, a message at a time

func NewReader

func NewReader(r io.Reader) *Reader

NewReader returns a reader of the messages of the mailbox, which can have any line endings, such as a Mac's carriage returns

func (*Reader) Next

func (r *Reader) Next() (*Message, error)

Next returns the next message of the mailbox, or io.EOF when there are no more. Text before the first From line isn't a message, and the blank line after a message, which separates it from the next, isn't part of it.

type Writer added in v1.0.5

type Writer struct {
	// contains filtered or unexported fields
}

Writer writes the messages of a mailbox, a message at a time, which the Reader reads as they were written

func NewWriter added in v1.0.5

func NewWriter(w io.Writer) *Writer

NewWriter returns a writer of the messages of a mailbox to w

func (*Writer) Write added in v1.0.5

func (w *Writer) Write(m *Message) error

Write writes a message: a From line, with its sender, or ???@??? when it has none, and its date, in UTC, then its data, whose lines end with line feeds, as any line ending is one, and whose lines which start with From, or one or more > and From, have a > before them, and a blank line after it, as the mboxrd format has them. A sender's spaces are underscores, as a From line's sender is one word.

Jump to

Keyboard shortcuts

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