eml

package
v1.1.12 Latest Latest
Warning

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

Go to latest
Published: Nov 23, 2026 License: Apache-2.0 Imports: 13 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 eml reads email messages, in the Internet Message Format, with MIME parts, such as .eml files, and the messages in a mailbox: their subject, addresses, date and identifier, their text and HTML, decoded from their transfer encoding and character set, and their attachments

Index

Constants

View Source
const ContentType = "message/rfc822"

ContentType is the content type of an email message

Variables

This section is empty.

Functions

This section is empty.

Types

type Attachment

type Attachment struct {
	// Its file name, which is empty when it has none
	Name string

	// Its content type, such as application/pdf, which is empty when it
	// isn't known
	ContentType string

	// Its content, decoded from its transfer encoding, which is nil for an
	// attachment which isn't in the message, such as one which Eudora
	// saved to a folder, and listed in the message's X-Attachments header
	Data []byte
}

Attachment is an attachment of an email message

type Message

type Message struct {
	// The message's header, as it is, which is empty for a message without
	// one, such as a message which Eudora saved without its header
	Header mail.Header

	// The subject, with its encoded words decoded, such as =?big5?B?...?=
	Subject string

	// The addresses of the senders, the recipients, and the recipients who
	// are copied, whose names have their encoded words decoded
	From, To, Cc []*mail.Address

	// When the message was sent, which is zero when it isn't known
	Date time.Time

	// The message's identifier, without its angle brackets
	MessageID string

	// The message's first plain text, and its first HTML, decoded from
	// their transfer encoding and character set, which are empty when it
	// has none. A message without a header is all text.
	Text, HTML string

	// The message's attachments, in their order
	Attachments []Attachment
}

Message is an email message

func Parse

func Parse(r io.Reader) (*Message, error)

Parse returns the email message, which is read to its end: its subject, addresses, date and identifier, its first plain text and HTML, and its attachments, including those which Eudora saved to a folder, and listed in its X-Attachments header. A message whose header can't be read, such as one which Eudora saved without it, is all text.

Jump to

Keyboard shortcuts

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