Help us shape the future of Go! Take the 2026 Go Developer Survey

mailparse

package
v0.2.0 Latest Latest
Warning

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

Go to latest
Published: Nov 3, 2026 License: MIT-0 Imports: 13 Imported by: 0

Documentation

Overview

Package mailparse extracts IMAP envelope metadata, a cached MIME tree, and full-text search text from raw RFC 5322 messages.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func DecodeMIMETree

func DecodeMIMETree(cached string, extended bool) (imap.BodyStructure, error)

DecodeMIMETree reconstructs a go-imap BodyStructure from the cached JSON.

Types

type Address

type Address struct {
	Name    string `json:"name,omitempty"`
	Address string `json:"address"`
}

Address is a decoded mailbox.

type Header struct {
	Name  string `json:"name"`
	Value string `json:"value"`
}

Header is one raw header field.

type Result

type Result struct {
	Subject     string
	MessageID   string
	From        []Address
	To          []Address
	Cc          []Address
	Bcc         []Address
	ReplyTo     []Address
	InReplyTo   []string
	References  []string
	Date        time.Time
	Headers     []Header
	Text        string
	HTML        string
	Attachments []string
	MIMETree    string
	Search      Search
}

Result is the parsed representation used for storage and search.

func Parse

func Parse(raw []byte) (*Result, error)

Parse parses a raw message. It never returns a partially initialized result: malformed messages fall back to a minimal header-only parse.

type Search struct {
	Subject     string
	Sender      string
	Recipients  string
	Headers     string
	Body        string
	Attachments string
}

Search is the text written to the FTS index.

Jump to

Keyboard shortcuts

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