emailparser

package module
v0.0.0-...-28d2930 Latest Latest
Warning

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

Go to latest
Published: Dec 12, 2023 License: Apache-2.0 Imports: 11 Imported by: 0

README

Go Email Parser

A small MIME encoded (A.K.A. EML files) email parser.

This has been used in production for some time, so we decided to extract it as open source.

Features

  • Parse email attachment recursively, as well as structured bounce messages.

TODO

  • comprehensive unit tests
  • CI/CD stuff
  • Documentation
  • Clean up API
  • Create eml2json command

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Headers

func Headers(p *Email) *mail.Header

func StripOutAttachments

func StripOutAttachments(p *Email)

StripOutAttachments removes raw attachments from a message, in order to save same space on its JSON encoded representation. TODO: maybe this would be better implemented in ParseFromReaderAsPartsWithBody instead, in a immutable fashion?

Types

type Email

type Email struct {
	Headers map[string][]string `json:"headers,omitempty"`
	Parts   []*Part             `json:"parts,omitempty"`
}

func ParseFromReader

func ParseFromReader(r io.Reader) (*Email, error)

type Part

type Part struct {
	ContentType        string                `json:"content_type"`
	ContentDisposition *string               `json:"content_disposition,omitempty"`
	AsText             *string               `json:"text,omitempty"`
	RawValue           []byte                `json:"raw,omitempty"`
	Parsed             *Email                `json:"parsed,omitempty"`
	Size               *int                  `json:"size,omitempty"`
	Checksum           *uint64               `json:"checksum,omitempty"`
	DeliveryStatus     []map[string][]string `json:"delivery_status,omitempty"`
}

Directories

Path Synopsis
cmd

Jump to

Keyboard shortcuts

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