pyemail

package
v1.1.2 Latest Latest
Warning

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

Go to latest
Published: Nov 21, 2026 License: MIT Imports: 14 Imported by: 0 modules, 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

Index

Constants

This section is empty.

Variables

View Source
var ErrEmbeddedHeader = errors.New("header value appears to contain an embedded header")

ErrEmbeddedHeader is the HeaderParseError of a value that would inject a header line

View Source
var ErrHeaderParse = errors.New("Base64 decoding error")

HeaderParseError is the error decode_header raises for an encoded word that does not decode

View Source
var ErrUnorderable = errors.New("'<' not supported between instances of 'NoneType' and 'int'")

ErrUnorderable is the TypeError of sorting continuations that mix numbered and unnumbered segments

Functions

func CollapseRFC2231Value

func CollapseRFC2231Value(p Param) string

Text of a parameter, an RFC2231 triple decoded from its charset with replacement, us-ascii when unnamed

func FormatDateLocal

func FormatDateLocal() string

RFC 2822 date of the current local time with its numeric zone

func Quote

func Quote(s string) string

Backslashes and double quotes escaped with a backslash

func Unquote

func Unquote(s string) string

Surrounding double quotes or angle brackets removed, quoted escapes undone

Types

type Address

type Address struct {
	Name string
	Addr string
}

Address is one parsed mailbox, its display name and addr-spec

func GetAddresses

func GetAddresses(fieldvalues []string) []Address

Real name and address pairs of the field values under the strict parser, one empty pair when the count is off

func ParseAddr

func ParseAddr(addr string) Address

Real name and address of one address field under the strict parser, an empty pair when it does not parse to exactly one

type DecodedPart

type DecodedPart struct {
	Text    string
	Bytes   []byte
	IsBytes bool
	Charset string
}

DecodedPart is one run of a decoded header, text for the single undecoded form and bytes with a charset otherwise

func DecodeHeader

func DecodeHeader(header HeaderValue) ([]DecodedPart, error)

Decodes a header value without converting charsets, one text part when it holds no encoded word

type HeaderValue

type HeaderValue string

HeaderValue is a raw header value, bytes above ASCII kept as they arrived

func (HeaderValue) Has8Bit

func (h HeaderValue) Has8Bit() bool

Whether the value carries bytes above ASCII, read by compat32 as an unknown-8bit Header

func (HeaderValue) Str

func (h HeaderValue) Str() string

str of the value, each byte above ASCII shown as the replacement character

type Message

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

Message is a parsed MIME message under the compat32 policy, header values and payload kept as raw bytes

func ParseBytes

func ParseBytes(raw []byte, headersOnly bool) *Message

Parses a whole message from bytes, headers only when asked with the rest of the text as its payload

func (*Message) Get

func (m *Message) Get(name string) (HeaderValue, bool)

First value of a header matched without case, false when the message has none

func (*Message) GetAll

func (m *Message) GetAll(name string) []HeaderValue

Every value of a header matched without case in message order

func (*Message) GetBoundary

func (m *Message) GetBoundary() (string, bool)

Boundary parameter of the Content-Type header with trailing white space removed

func (*Message) GetContentCharset

func (m *Message) GetContentCharset() (string, bool)

Lowercased charset parameter of the Content-Type header, false when missing or not ASCII

func (*Message) GetContentMaintype

func (m *Message) GetContentMaintype() string

func (*Message) GetContentSubtype

func (m *Message) GetContentSubtype() string

func (*Message) GetContentType

func (m *Message) GetContentType() string

Lowercased maintype/subtype of the Content-Type header, the default type without one and text/plain for a malformed one

func (*Message) GetFilename

func (m *Message) GetFilename() (string, bool)

File name of the payload from the Content-Disposition filename, else the Content-Type name

func (*Message) GetPayloadDecoded

func (m *Message) GetPayloadDecoded() []byte

Payload decoded by its Content-Transfer-Encoding, nil for a multipart message

func (*Message) IsMultipart

func (m *Message) IsMultipart() bool

Whether the payload is a list of sub messages

func (*Message) Items

func (m *Message) Items() [][2]string

Header names and values in message order

func (*Message) Walk

func (m *Message) Walk() []*Message

The message and every sub message in depth first order

type Param

type Param struct {
	Name     string
	Value    string
	RFC2231  bool
	Charset  *string
	Language *string
}

Param is one header parameter, RFC2231 set when the value is the charset, language and text triple

func GetParams

func GetParams(header string) ([]Param, error)

Unquoted parameters of a header value, the first being the main value with an empty parameter value

type Part

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

Part is a MIME entity under construction, a leaf with an encoded text payload or a multipart container

func NewBase64

func NewBase64(maintype, subtype string, data []byte) *Part

Binary part of the given type carried as base64, its last line unterminated unless the data ends in a line feed

func NewMultipart

func NewMultipart() *Part

Empty multipart/mixed container with its MIME version header

func NewTextUTF8

func NewTextUTF8(body string) *Part

Plain text part in utf-8 carried as base64

func (*Part) AsBytes

func (p *Part) AsBytes() ([]byte, error)

Bytes of the message as the SMTP generator writes it, lines ended by CRLF

func (*Part) Attach

func (p *Part) Attach(sub *Part)

Adds a sub part to a multipart container

func (*Part) Get

func (p *Part) Get(name string) (string, bool)

First value of a header matched without case

func (*Part) GetAll

func (p *Part) GetAll(name string) []string

Every value of a header matched without case in order

func (*Part) Set

func (p *Part) Set(name, value string)

Appends a header, a name already present kept beside it

func (*Part) Without

func (p *Part) Without(names ...string) *Part

Shallow copy of the entity without the named headers

Jump to

Keyboard shortcuts

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