Message

A message is an immutable, locally normalized inbound email. It is evidence imported from one mailbox, not a live provider object.

Overview#

A message is an immutable, locally normalized inbound email. It is evidence imported from one mailbox, not a live provider object.

Shape#

FieldMeaning
idlocal UUID
mailbox_idreceiving mailbox
external_uidprovider IMAP UID within that mailbox
message_idoptional RFC Message-ID header
in_reply_to, referencesoptional thread headers
sender, reply_to, recipientsnormalized header text
subjectSubject, or (no subject)
sent_atparsed provider Date, or null
received_atlocal import timestamp
body_textfirst available text/plain body, trimmed
snippetcollapsed whitespace, first 240 characters

Creation#

A sync searches UIDs after the mailbox cursor and requests each with BODY.PEEK[]; it does not set a Seen flag. Missing bodies, or messages that cannot normalize, are counted as skipped. Skrzynka stores no raw MIME, attachment, or remote HTML.

The database uniqueness key is (mailbox_id, external_uid). Importing the same UID again uses INSERT OR IGNORE, so the existing row and UUID remain unchanged.

Lifecycle#

There is no message update or single-message delete interface. A message remains until its mailbox is removed or the database is removed/restored. Message lists are newest local receipt first; mailbox_id can filter them. Without limit a list carries every message; limit=0 is refused with LIMIT_INVALID.

A reply targets reply_to when present, otherwise sender, and carries the inbound Message-ID into In-Reply-To and References.

Invariants and refusals#

  • IMAP UID is meaningful only inside its mailbox.
  • Reads are constrained through the mailbox's organization.
  • Unknown UUID: NOT_FOUND — message was not found.
  • Invalid API UUID text: INVALID_IDENTIFIER — identifier is not a valid UUID.
  • A malformed provider message can produce MESSAGE_MALFORMED with provider message could not be parsed or provider message has no From header; synchronization skips it rather than exposing provider content.
  • A message without a valid reply target is refused as MESSAGE_REPLY_TARGET_INVALID — message has no valid Reply-To or From address.

See synchronization and reply attempt.