mail

package
v0.1.3 Latest Latest
Warning

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

Go to latest
Published: Nov 15, 2023 License: MIT Imports: 6 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func FindText added in v0.1.2

func FindText(ctx context.Context, mailer Mailer, email string, textRegexp *regexp.Regexp, f *Filter) (text string, found bool, err error)

FindText find text from emails. If textRegexp is nil, return the body of the latest email which matches the headerFilter.

Types

type Body

type Body struct {
	Text string `json:"text"`
	HTML string `json:"html"`
}

Body is the body of a mail.

type Filter added in v0.1.2

type Filter struct {
	SendTime      time.Time      // if not zero, filter mails received after this time.
	From          string         // if not empty, filter emails FROM equal to this value.
	FromRegexp    *regexp.Regexp // if not nil, filter emails FROM matching this regular expression.
	Subject       string         // is not empty, filter emails SUBJECT equal to this value.
	SubjectRegexp *regexp.Regexp // if not nil, filter emails SUBJECT matching this regular expression.
}

Filter options to filter emails.

type Header struct {
	Address string    `json:"address"`
	ID      string    `json:"id"`
	From    string    `json:"from"`
	To      []string  `json:"to"`
	Subject string    `json:"subject"`
	Date    time.Time `json:"date"`
	Size    int64     `json:"size"`
	Seen    bool      `json:"seen"`
}

Header is the header of a mail.

type Mailer

type Mailer interface {
	// List returns a list of message headers for the requested address.
	List(ctx context.Context, address string) ([]*Header, error)

	// Get returns the message body by a address name and message ID.
	Get(ctx context.Context, address string, id string) (*Body, error)

	// Del deletes a single message given the address name and message ID.
	Del(ctx context.Context, address string, id string) error

	// Clear deletes all messages in the given address.
	Clear(ctx context.Context, address string) error

	// Domain returns the domain of the mailer.
	Domain() string
}

Mailer is a mail client to send and get mails.

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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