mailtest

package
v0.2.0 Latest Latest
Warning

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

Go to latest
Published: Oct 9, 2026 License: AGPL-3.0 Imports: 11 Imported by: 0

Documentation

Overview

Package mailtest is an in-memory mail.Mailbox for tests of the packages that sit on top of the connector. It keeps the same promises as the IMAP one: UIDs only grow, a moved message gets a new UID in its destination, fetching never sets \Seen, and a reference with the wrong UIDVALIDITY finds nothing.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Mailbox

type Mailbox struct {
	AccountID int64
	Caps      mail.Caps
	// contains filtered or unexported fields
}

Mailbox is the fake. Set Caps before use to simulate a limited server.

func New

func New(accountID int64) *Mailbox

New returns a mailbox with an empty INBOX on a server that supports everything.

func (*Mailbox) AddFolder

func (m *Mailbox) AddFolder(name, role string)

AddFolder creates a folder with a special-use role ("" for none). Re-adding an existing name rebuilds it empty with a new UIDVALIDITY.

func (*Mailbox) Capabilities

func (m *Mailbox) Capabilities() mail.Caps

Capabilities returns Caps.

func (*Mailbox) Close

func (m *Mailbox) Close() error

Close does nothing.

func (*Mailbox) Deliver

func (m *Mailbox) Deliver(folderName, eml string, flags ...string) mail.MsgRef

Deliver puts an RFC 5322 message into a folder, as new mail arriving, and wakes watchers.

func (*Mailbox) EnsureFolder

func (m *Mailbox) EnsureFolder(ctx context.Context, name string) error

EnsureFolder creates the folder if it is missing.

func (*Mailbox) Fetch

func (m *Mailbox) Fetch(ctx context.Context, ref mail.MsgRef, maxBody int) (*message.Raw, error)

Fetch returns a copy of the message with its text cut to maxBody bytes. Flags are untouched.

func (*Mailbox) FetchMany

func (m *Mailbox) FetchMany(ctx context.Context, refs []mail.MsgRef, maxBody int) ([]*message.Raw, error)

FetchMany returns a copy of each message, like Fetch, and nil for one that is gone.

func (*Mailbox) FetchSince

func (m *Mailbox) FetchSince(ctx context.Context, name string, since time.Time, limit int) ([]mail.MsgRef, int, error)

FetchSince lists messages delivered at or after since, oldest first, newest limit only.

func (*Mailbox) FindByMessageID

func (m *Mailbox) FindByMessageID(ctx context.Context, name, messageID string) (mail.MsgRef, error)

FindByMessageID returns the newest message in the folder with that Message-ID.

func (*Mailbox) Flags

func (m *Mailbox) Flags(ctx context.Context, ref mail.MsgRef) ([]string, error)

Flags returns the message's flags, sorted.

func (*Mailbox) Folders

func (m *Mailbox) Folders(ctx context.Context) ([]mail.Folder, error)

Folders lists folders by name.

func (*Mailbox) Move

func (m *Mailbox) Move(ctx context.Context, ref mail.MsgRef, dest string) (mail.MsgRef, error)

Move takes the message out of its folder and gives it a new UID in dest.

func (*Mailbox) SentRecipients

func (m *Mailbox) SentRecipients(ctx context.Context, name string, limit int) ([]mail.Recipient, error)

SentRecipients returns the To and Cc addresses of the newest limit messages.

func (*Mailbox) SetFlags

func (m *Mailbox) SetFlags(ctx context.Context, ref mail.MsgRef, add, remove []string) error

SetFlags adds and removes flags.

func (*Mailbox) Status

func (m *Mailbox) Status(ctx context.Context, name string) (mail.FolderStatus, error)

Status returns the folder's UIDVALIDITY and next UID.

func (*Mailbox) Watch

func (m *Mailbox) Watch(ctx context.Context, name string, lastUID uint32, out chan<- mail.NewMail) error

Watch sends every message above lastUID, then each delivery, until ctx is done.

Jump to

Keyboard shortcuts

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