imapc

package
v1.45.1 Latest Latest
Warning

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

Go to latest
Published: Oct 16, 2026 License: 0BSD Imports: 11 Imported by: 0

Documentation

Overview

Package imapc is the IMAP4rev1 client the reply-by-mail poller needs (#295): LOGIN, SELECT or EXAMINE, UID SEARCH UNSEEN, UID FETCH BODY.PEEK[], UID STORE +FLAGS (\Seen), LOGOUT. Nothing else. The connection is TLS from the first byte or upgraded with STARTTLS before LOGIN; there is no plaintext mode.

Index

Constants

View Source
const MaxMessage = 10 << 20

MaxMessage is the largest message Fetch returns; a larger one is refused by its RFC822.SIZE before its body is fetched (ErrTooLarge).

View Source
const MaxUnseen = 10000

MaxUnseen is the most UIDs Unseen returns; the rest wait for the next poll.

Variables

View Source
var (
	ErrTooLarge = errors.New("message larger than the fetch limit")
	ErrLimit    = errors.New("IMAP server exceeded a response limit; connection closed")
)

Functions

This section is empty.

Types

type Client

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

Client is one authenticated IMAP session.

func Dial

func Dial(addr string, starttls bool, timeout time.Duration) (*Client, error)

Dial connects to addr (host:port) and reads the greeting. With starttls it upgrades the connection before returning; otherwise TLS runs from the first byte.

func New

func New(conn net.Conn) *Client

New wraps a connection that is already past its TLS handshake, or a test's pipe. The greeting has not been read.

func Open

func Open(in config.MailInbound, readOnly bool, timeout time.Duration) (*Client, int, error)

Open connects to the configured mailbox, logs in with the password file's password, and opens the mailbox: read-only (EXAMINE) or for setting flags (SELECT). It returns the number of messages in it.

func (*Client) Close

func (c *Client) Close() error

Close logs out and closes the connection.

func (*Client) Examine

func (c *Client) Examine(mailbox string) (int, error)

func (*Client) Fetch

func (c *Client) Fetch(uid uint32) ([]byte, error)

Fetch returns the whole message without setting \Seen. A message over MaxMessage is refused by its size first. A server answering BODY[] with NIL or "" returns an empty message.

func (*Client) Login

func (c *Client) Login(user, pass string) error

Login authenticates. The password goes as a quoted string, so it may not hold a line break or a byte outside printable ASCII.

func (*Client) MarkSeen

func (c *Client) MarkSeen(uid uint32) error

MarkSeen sets \Seen.

func (*Client) Select

func (c *Client) Select(mailbox string) (int, error)

Select opens mailbox for reading and writing flags; Examine opens it read-only. Both return the number of messages in it.

func (*Client) SetDeadline

func (c *Client) SetDeadline(t time.Time) error

SetDeadline bounds the session's remaining I/O.

func (*Client) Unseen

func (c *Client) Unseen() ([]uint32, error)

Unseen returns the UIDs of messages without \Seen.

type RefusedError

type RefusedError struct{ Text string }

RefusedError is the server answering a command NO or BAD, or answering a FETCH with no message: a refusal of that command, with the session still usable.

func (*RefusedError) Error

func (e *RefusedError) Error() string

Source Files

  • imapc.go
  • open.go

Jump to

Keyboard shortcuts

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