imapclt

package
v0.6.0 Latest Latest
Warning

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

Go to latest
Published: Jan 31, 2026 License: EUPL-1.2 Imports: 16 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Client

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

func NewClient

func NewClient(cfg *Config) *Client

NewClient creates an new IMAP-Client. *Client.Connect must be called before any other methods.

func (*Client) Close

func (c *Client) Close() error

func (*Client) Connect

func (c *Client) Connect() error

Connect establishes a connection the IMAP-Server.

func (*Client) Messages

func (c *Client) Messages(mailbox string) iter.Seq2[*Message, error]

Messages returns an iterator over the messages in mailbox. When an error happens a nil message and an error is passed via the yield function.

func (*Client) Monitor

func (c *Client) Monitor(mailbox string) (
	_ <-chan *EventNewMessages, stop func() error, _ error,
)

Monitor starts to monitor mailbox for new messages. When new messages are found an event is sent to ch. Message delivery to ch must not block. If delievery would block the message is discarded.

While Monitor is running, running other IMAP operations will block forever! To issue other IMAP operations, the returned stop function must be called before!

func (*Client) Move

func (c *Client) Move(uids []uint32, mailbox string) error

Move moves the messages with the given uids to mailbox.

func (*Client) Upload

func (c *Client) Upload(path, mailbox string, ts time.Time) error

Upload reads a message (mail) from file and appends it to an imap mailbox. The internal date of the message is set to ts.

type Config

type Config struct {
	// Address is the address of the IMAP server. If the port is "993" or
	// "imaps" an implicit TLS (SSL) is established.
	// Otherwise a explicitl TLS (STARTTLS) connection is established.
	Address  string
	User     string
	Password string
	// AllowInsecure enables falling back to establishing the
	// connection without encryption when the server does not support TLS
	AllowInsecure bool
	Logger        *slog.Logger
	// LogIMAPData enables logging raw IMAP protocol data with debug
	// priority, it can contain sensitive information
	LogIMAPData bool
}

type DebugWriter added in v0.5.1

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

func NewDebugWriter added in v0.5.1

func NewDebugWriter(l *slog.Logger) *DebugWriter

func (*DebugWriter) Write added in v0.5.1

func (w *DebugWriter) Write(p []byte) (n int, err error)

type DryClient

type DryClient struct {
	*Client
}

DryClient is an IMAP client that simulates operations that do changes on the IMAP-Server.

func NewDryClient

func NewDryClient(cfg *Config) *DryClient

NewDryClient creates an new IMAP-Client. [*DryClient.Connect] must be called before any other methods.

func (*DryClient) Move

func (c *DryClient) Move(uids []uint32, mailbox string) error

Move logs a debug message and returns nil

func (*DryClient) Upload

func (c *DryClient) Upload(path, mailbox string, _ time.Time) error

Upload logs a debug message and returns nil

type Envelope

type Envelope struct {
	Date    time.Time
	Subject string
	From    []string
	// Recipients are the To, Cc and Bcc addresses
	Recipients []string
	MessageID  string
}

type ErrMalformedMsg added in v0.5.1

type ErrMalformedMsg struct {
	Err string
	UID uint32
}

func NewErrMalformedMsg added in v0.5.1

func NewErrMalformedMsg(err string, uid uint32) *ErrMalformedMsg

func (*ErrMalformedMsg) Error added in v0.5.1

func (e *ErrMalformedMsg) Error() string

type EventNewMessages

type EventNewMessages struct {
	NewMsgCount uint32
}

type Message

type Message struct {
	UID      uint32
	Message  io.Reader
	Envelope Envelope
}

Jump to

Keyboard shortcuts

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