email

package
v1.2.2 Latest Latest
Warning

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

Go to latest
Published: Dec 10, 2023 License: MIT-0 Imports: 12 Imported by: 0

README

Parse email

Parse email string to appropriate struct for easy access data and manipulate it. More information about fields you can find here

email, err := email.Parse(ioReaderWithEmailData)
// or
email, err := email.Parse(strings.NewReader(emailRawStringData))
if err != nil {
    // handle error
}

fmt.Print(email.Subject)

Documentation

Index

Constants

This section is empty.

Variables

View Source
var ErrEmptyString = errors.New("EOF")

Functions

This section is empty.

Types

type Attachment

type Attachment struct {
	Filename    string
	ContentType string
	Data        io.Reader
}

Attachment represents file data with filename, content type and data (as an io.Reader)

type Email

type Email struct {
	// Headers full set for easier access to extra fields
	Headers mail.Header

	Subject    string
	Sender     *mail.Address
	From       []*mail.Address
	ReplyTo    []*mail.Address
	To         []*mail.Address
	Cc         []*mail.Address
	Bcc        []*mail.Address
	Date       time.Time
	MessageID  string
	InReplyTo  []string
	References []string

	ResentFrom      []*mail.Address
	ResentSender    *mail.Address
	ResentTo        []*mail.Address
	ResentDate      time.Time
	ResentCc        []*mail.Address
	ResentBcc       []*mail.Address
	ResentMessageID string

	ContentType string
	Content     io.Reader

	HTMLBody string
	TextBody string

	Attachments   []Attachment
	EmbeddedFiles []EmbeddedFile
}

Email with fields for all the headers defined in RFC5322 with attachments and embedded files

func Parse

func Parse(r io.Reader) (email *Email, err error)

Parse an email message read from io.Reader into email.Email struct

type EmbeddedFile

type EmbeddedFile struct {
	CID         string
	ContentType string
	Data        io.Reader
}

EmbeddedFile represents file data with content id, content type and data (as an io.Reader)

Jump to

Keyboard shortcuts

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