emlparser

package
v0.0.5 Latest Latest
Warning

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

Go to latest
Published: May 6, 2023 License: MIT Imports: 16 Imported by: 0

Documentation

Overview

Package mail implements a parser for electronic mail messages as specified in RFC5322.

We allow both CRLF and LF to be used in the input, possibly mixed.

Index

Constants

View Source
const (
	CR = '\r'
	LF = '\n'
)

Variables

View Source
var CRLF = []byte{CR, LF}

Functions

func ParseDate

func ParseDate(s string) time.Time

Types

type Address

type Address interface {
	String() string
	Name() string
	Email() string
}

func ParseAddress

func ParseAddress(bs []byte) (Address, error)

type Attachment

type Attachment struct {
	Filename string
	Data     []byte
}

type GroupAddr

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

func (GroupAddr) Email

func (ga GroupAddr) Email() string

func (GroupAddr) Name

func (ga GroupAddr) Name() string

func (GroupAddr) String

func (ga GroupAddr) String() string
type Header struct {
	Key, Value string
}

type HeaderInfo

type HeaderInfo struct {
	FullHeaders []Header // all headers
	OptHeaders  []Header // unprocessed headers

	MessageId   string
	Id          string
	Date        time.Time
	From        []Address
	Sender      Address
	ReplyTo     []Address
	To          []Address
	Cc          []Address
	Bcc         []Address
	Subject     string
	Comments    []string
	Keywords    []string
	ContentType string

	InReply    []string
	References []string
}

type MailboxAddr

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

func (MailboxAddr) Email

func (ma MailboxAddr) Email() string

func (MailboxAddr) Name

func (ma MailboxAddr) Name() string

func (MailboxAddr) String

func (ma MailboxAddr) String() string

type Message

type Message struct {
	HeaderInfo
	Body        []byte
	Text        []byte
	Html        []byte
	Attachments []Attachment
	//除了附件外的数据(图片等)
	OtherAttachments []Attachment
	Parts            []Part
}

func Parse

func Parse(file *os.File, savefile bool) (m Message, e error)

func Process

func Process(r RawMessage, savefile bool) (m Message, e error)

type Part

type Part struct {
	Type    string
	Charset string
	Data    []byte
	Headers map[string][]string
}

type RawHeader

type RawHeader struct {
	Key, Value []byte
}

type RawMessage

type RawMessage struct {
	RawHeaders []RawHeader
	Body       []byte
	Reader     *bufio.Reader
}

func ParseRaw

func ParseRaw(reader *bufio.Reader) (m RawMessage, e error)

Jump to

Keyboard shortcuts

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