Skip to content

The mailbox directory

Martin Hebnes Pedersen edited this page Dec 13, 2021 · 5 revisions

Pat's mailbox design is focused on simplicity. Messages are stored as individual files in a simple directory structure.

No internal database or index is used. Pat scans the directory and monitors for file system events to maintain an updated view of its content, regardless of what application triggers the changes.

The primary reason for this design is that users can synchronize and share their mailbox across multiple devices using existing tools like rsync, Syncthing or even Dropbox.

Directory overview

The default mailbox path is $HOME/.wl2k/mailbox/ in pre-v0.12 releases, or can be found in newer releases with pat help or pat env. It can be customized by the --mbox command line option.

Inside the root mailbox directory, a subdirectory for each callsign is created automatically by Pat. Each subdirectory contains 4 additional directories:

name description
in/ Received messages are stored here
out/ Pending outbound messages are stored here
sent/ Outbound messages are moved here once successfully delivered
archive/ Users can move sent and received messages here for archiving

All other subdirectories are ignored by Pat.

The message files

Each message is represented as single file in the mailbox directory. They are named by their unique Message ID (MID), using the extension .b2f.

Messages are stored (uncompressed) in the same binary format as they are transmitted in. See https://www.winlink.org/B2F for a detailed overview.

Mailbox synchronization

Although virtually any sync tool can be used, Syncthing has proven to be very versatile and reliable. Much like Pat, Syncthing is an open source application written in Go to support a variety of platforms (including the Raspberry Pi).

Syncthing is decentralized, meaning it works just as well on a private network (off-grid) as over the Internet.

(anyone is welcome to add a brief getting-started guide, ref Issue #17)