maildir

package
v0.42.0 Latest Latest
Warning

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

Go to latest
Published: Jun 15, 2026 License: MIT Imports: 17 Imported by: 0

Documentation

Overview

Package maildir implements the backend.Provider interface for local Maildir mailboxes (the `mutt -f Maildir` style). It is read/edit only — there is no SMTP transport, so SendEmail returns ErrNotSupported.

Folder layout follows Maildir++:

  • The configured root path is "INBOX".
  • Sibling directories prefixed with "." (e.g. ".Sent", ".Archive") are additional folders. Inner dots map to a "/" hierarchy.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Provider

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

Provider implements backend.Provider against a local Maildir tree. Two on-disk layouts are supported:

  • Maildir++ (dovecot style): the root itself is INBOX (has cur/new/tmp), and subfolders are sibling directories prefixed with "." (e.g. ".Sent").
  • Nested (mbsync/isync/fastmail style): the root contains one directory per folder, each holding its own cur/new/tmp. INBOX is the child directory named "INBOX".

The layout is auto-detected at New() time by probing for `<root>/cur`.

func New

func New(account *config.Account) (*Provider, error)

New creates a new Maildir provider for the given account.

func (*Provider) ArchiveEmail

func (p *Provider) ArchiveEmail(ctx context.Context, folder string, uid uint32) error

ArchiveEmail moves the message to the Archive subfolder if one exists.

func (*Provider) ArchiveEmails

func (p *Provider) ArchiveEmails(ctx context.Context, folder string, uids []uint32) error

ArchiveEmails archives the listed messages.

func (*Provider) Capabilities

func (p *Provider) Capabilities() backend.Capabilities

Capabilities reports what the Maildir backend can do.

func (*Provider) Close

func (p *Provider) Close() error

Close releases any provider-held resources. None for Maildir.

func (*Provider) DeleteEmail

func (p *Provider) DeleteEmail(_ context.Context, folder string, uid uint32) error

DeleteEmail removes the message file from disk.

func (*Provider) DeleteEmails

func (p *Provider) DeleteEmails(ctx context.Context, folder string, uids []uint32) error

DeleteEmails removes the listed messages from the folder.

func (*Provider) FetchAttachment

func (p *Provider) FetchAttachment(_ context.Context, folder string, uid uint32, partID, _ string) ([]byte, error)

FetchAttachment returns the raw bytes of an attachment part.

func (*Provider) FetchEmailBody

func (p *Provider) FetchEmailBody(_ context.Context, folder string, uid uint32) (string, string, []backend.Attachment, error)

FetchEmailBody returns the chosen body, MIME type, and attachments.

func (*Provider) FetchEmails

func (p *Provider) FetchEmails(_ context.Context, folder string, limit, offset uint32) ([]backend.Email, error)

FetchEmails returns messages from the folder, newest first. Any messages sitting in new/ are first promoted to cur/ (same semantics as mutt opening a Maildir): they remain unread (no Seen flag) but become trackable.

func (*Provider) FetchFolders

func (p *Provider) FetchFolders(_ context.Context) ([]backend.Folder, error)

FetchFolders returns INBOX plus any subfolders found at the root, using whichever on-disk layout the provider detected.

func (*Provider) MarkAsRead

func (p *Provider) MarkAsRead(_ context.Context, folder string, uid uint32) error

MarkAsRead sets the Seen flag while preserving the others.

func (*Provider) MarkAsUnread added in v0.39.0

func (p *Provider) MarkAsUnread(_ context.Context, folder string, uid uint32) error

MarkAsUnread removes the Seen flag while preserving the others.

func (*Provider) MoveEmail

func (p *Provider) MoveEmail(_ context.Context, uid uint32, srcFolder, dstFolder string) error

MoveEmail relocates a message between two Maildir folders.

func (*Provider) MoveEmails

func (p *Provider) MoveEmails(ctx context.Context, uids []uint32, srcFolder, dstFolder string) error

MoveEmails relocates the listed messages between folders.

func (*Provider) Search

func (p *Provider) Search(_ context.Context, folder string, query backend.SearchQuery) ([]backend.Email, error)

Search filters messages in a folder by the given query, parsing headers locally. Body matching scans the decoded body parts.

func (*Provider) SendEmail

func (p *Provider) SendEmail(_ context.Context, _ *backend.OutgoingEmail) error

SendEmail is not supported by the Maildir backend.

func (*Provider) Watch

func (p *Provider) Watch(_ context.Context, _ string) (<-chan backend.NotifyEvent, func(), error)

Watch is not supported. Future: fsnotify on new/ to emit NotifyNewEmail.

Jump to

Keyboard shortcuts

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