imap

package
v1.23.0 Latest Latest
Warning

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

Go to latest
Published: Oct 10, 2026 License: MIT Imports: 17 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Params added in v1.20.0

func Params() []string

Params returns the keys the imap action takes in with.

func Request added in v1.18.0

func Request(data map[string]any, opts ...Option) (map[string]any, error)

func Serve

func Serve()

Types

type Action

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

func (*Action) Run

func (a *Action) Run(with map[string]any) (map[string]any, error)

type Callback added in v1.18.0

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

type Command added in v1.18.0

type Command struct {
	Name       string   `map:"name" validate:"required"`
	Mailbox    string   `map:"mailbox"`
	OldMailbox string   `map:"oldmailbox"`
	NewMailbox string   `map:"newmailbox"`
	Reference  string   `map:"reference"`
	Pattern    string   `map:"pattern"`
	Criteria   Criteria `map:"criteria"`
	Sequence   string   `map:"sequence"`
	Dataitem   string   `map:"dataitem"`
	Value      string   `map:"value"`
}

Without login, logout and Expunge

type CopyData added in v1.18.0

type CopyData struct {
	Success bool `map:"success"`
	Count   int  `map:"count"`
}

type CreateData added in v1.18.0

type CreateData struct {
	Success bool   `map:"success"`
	Mailbox string `map:"mailbox"`
}

type Criteria added in v1.18.0

type Criteria struct {
	SeqNums    []string          `map:"seq_nums"`
	UIDs       []string          `map:"uids"`
	Since      string            `map:"since"`
	Before     string            `map:"before"`
	SentSince  string            `map:"sent_since"`
	SentBefore string            `map:"sent_before"`
	Headers    map[string]string `map:"headers"`
	Bodies     []string          `map:"bodies"`
	Texts      []string          `map:"texts"`
	Flags      []string          `map:"flags"`
	NotFlags   []string          `map:"not_flags"`
}

type Data added in v1.18.0

type Data struct {
	Select      SelectData `map:"select"`
	Examine     SelectData `map:"examine"`
	Search      SearchData `map:"search"`
	List        ListData   `map:"list"`
	Fetch       FetchData  `map:"fetch"`
	Store       StoreData  `map:"store"`
	Copy        CopyData   `map:"copy"`
	Create      CreateData `map:"create"`
	Delete      DeleteData `map:"delete"`
	Rename      RenameData `map:"rename"`
	Subscribe   StatusData `map:"subscribe"`
	Unsubscribe StatusData `map:"unsubscribe"`
	Noop        NoopData   `map:"noop"`
}

type DeleteData added in v1.18.0

type DeleteData struct {
	Success bool   `map:"success"`
	Mailbox string `map:"mailbox"`
}

type FetchData added in v1.18.0

type FetchData struct {
	Messages []Message `map:"messages"`
	Count    int       `map:"count"`
}

type ListData added in v1.18.0

type ListData struct {
	Mailboxes []MailboxInfo `map:"mailboxes"`
	Count     int           `map:"count"`
}

type MailboxInfo added in v1.18.0

type MailboxInfo struct {
	Name       string   `map:"name"`
	Attributes []string `map:"attributes"`
	Delimiter  string   `map:"delimiter"`
}

type Message added in v1.18.0

type Message struct {
	UID   int      `map:"uid"`
	Flags []string `map:"flags"`
	// Date is the envelope's Date in RFC 3339, such as
	// 2025-10-08T07:11:55Z. A time.Time came out of the result as an empty
	// map.
	Date     string            `map:"date"`
	From     string            `map:"from"`
	To       string            `map:"to"`
	Subject  string            `map:"subject"`
	Body     string            `map:"body"`
	HTMLBody string            `map:"html_body"`
	Size     int               `map:"size"`
	Headers  map[string]string `map:"headers"`
}

Message represents an email message

type NoopData added in v1.18.0

type NoopData struct {
	Success bool `map:"success"`
}

type Option added in v1.18.0

type Option func(*Callback)

func WithAfter added in v1.18.0

func WithAfter(f func(res *Res)) Option

func WithBefore added in v1.18.0

func WithBefore(f func(req *Req)) Option

type RenameData added in v1.18.0

type RenameData struct {
	Success    bool   `map:"success"`
	OldMailbox string `map:"old_mailbox"`
	NewMailbox string `map:"new_mailbox"`
}

type Req added in v1.18.0

type Req struct {
	Host            string        `map:"host" validate:"required"`
	Port            int           `map:"port" validate:"required"`
	Username        string        `map:"username" validate:"required"`
	Password        string        `map:"password" validate:"required"`
	TLS             bool          `map:"tls"`
	Timeout         time.Duration `map:"timeout"`
	InsecureSkipTLS bool          `map:"insecure_skip_tls"`
	Commands        []Command     `map:"commands"`
	// contains filtered or unexported fields
}

func NewReq added in v1.18.0

func NewReq() *Req

func (*Req) Copy added in v1.18.0

func (r *Req) Copy(sequence, mailbox string, uid bool) (*CopyData, error)

Copy implements COPY and UID COPY: it copies the given messages into mailbox. Count is the number of messages the server reports copied, which it does when it supports UIDPLUS; otherwise it is 0.

func (*Req) Create added in v1.18.0

func (r *Req) Create(mailbox string) (*CreateData, error)

Create implements CREATE command

func (*Req) Delete added in v1.18.0

func (r *Req) Delete(mailbox string) (*DeleteData, error)

Delete implements DELETE command

func (*Req) Do added in v1.18.0

func (r *Req) Do() (*Result, error)

func (*Req) Examine added in v1.18.0

func (r *Req) Examine(mb string) (*SelectData, error)

Examine implements EXAMINE command (read-only SELECT)

func (*Req) ExecCommands added in v1.18.0

func (r *Req) ExecCommands() (*Data, error)

DEBUG: hclog.Default().Info(fmt.Sprintf("%#v\n", data))

func (*Req) Fetch added in v1.18.0

func (r *Req) Fetch(sequence, dataitem string) (*FetchData, error)

Fetch implements FETCH command

func (*Req) List added in v1.18.0

func (r *Req) List(ref, pattern string) (*ListData, error)

List implements LIST command

func (*Req) Noop added in v1.18.0

func (r *Req) Noop() (*NoopData, error)

Noop implements NOOP command

func (*Req) Rename added in v1.18.0

func (r *Req) Rename(oldMailbox, newMailbox string) (*RenameData, error)

Rename implements RENAME command

func (*Req) Search added in v1.18.0

func (r *Req) Search(cr *Criteria) (*SearchData, error)

func (*Req) Select added in v1.18.0

func (r *Req) Select(mb string) (*SelectData, error)

func (*Req) Store added in v1.18.0

func (r *Req) Store(sequence, dataitem, value string, uid bool) (*StoreData, error)

Store implements STORE and UID STORE: it changes the flags of the given messages. dataitem is FLAGS, +FLAGS or -FLAGS, optionally followed by .SILENT, and value lists the flags, as in "\Seen \Flagged" or "(\Seen)".

func (*Req) Subscribe added in v1.18.0

func (r *Req) Subscribe(mailbox string) (*StatusData, error)

Subscribe implements SUBSCRIBE command

func (*Req) UIDFetch added in v1.18.0

func (r *Req) UIDFetch(sequence, dataitem string) (*FetchData, error)

func (*Req) UIDSearch added in v1.18.0

func (r *Req) UIDSearch(cr *Criteria) (*SearchData, error)

func (*Req) Unsubscribe added in v1.18.0

func (r *Req) Unsubscribe(mailbox string) (*StatusData, error)

Unsubscribe implements UNSUBSCRIBE command

type Res added in v1.18.0

type Res struct {
	Code  int    `map:"code"`
	Data  Data   `map:"data"`
	Error string `map:"error"`
}

type Result added in v1.18.0

type Result struct {
	Req    Req           `map:"req"`
	Res    Res           `map:"res"`
	RT     time.Duration `map:"rt"`
	Status int           `map:"status"`
}

type SearchData added in v1.18.0

type SearchData struct {
	All   string `map:"all"`
	Min   int    `map:"min"`
	Max   int    `map:"max"`
	Count int    `map:"count"`
}

type SelectData added in v1.18.0

type SelectData struct {
	Exists         int      `map:"exists"`
	Recent         int      `map:"recent"`
	FirstUnseen    int      `map:"first_unseen"`
	UIDNext        int      `map:"uid_next"`
	Flags          []string `map:"flags"`
	PermanentFlags []string `map:"permanent_flags"`
}

type StatusData added in v1.18.0

type StatusData struct {
	Success bool   `map:"success"`
	Mailbox string `map:"mailbox"`
}

type StoreData added in v1.18.0

type StoreData struct {
	Success bool `map:"success"`
	Count   int  `map:"count"`
}

Jump to

Keyboard shortcuts

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