sandbox_corpus: Generate a Deterministic Synthetic Mail Corpus

View source: R/sandbox-corpus.R

sandbox_corpusR Documentation

Generate a Deterministic Synthetic Mail Corpus

Description

Generates a reproducible corpus of synthetic RFC 822 messages to be stored in a mailbox with populate_sandbox, so that the package's searching, fetching, and decoding features can be demonstrated and tested without a real mail account – typically against the local Docker IMAP sandbox shipped in system.file("docker", package = "mRpostman").

Usage

sandbox_corpus(n = 200, seed = 3501)

Arguments

n

Number of messages to generate. Default is 200.

seed

An integer used as the RNG seed. The same n and seed always produce byte-identical messages. Default is 3501, after RFC 3501. The caller's RNG state is preserved.

Details

Message features are spread so that each capability of the package has matching messages to act upon: Date: headers spread over 2020 (SENTBEFORE/SENTSINCE/SENTON searches); a subset of large bodies (LARGER/SMALLER searches); accented subjects in MIME encoded-words and quoted-printable bodies (header and body decoding); CSV, PNG, and one-page PDF attachments – all generated deterministically in base R – some with repeated filenames (attachment listing, fetching, binary base64 decoding, and filename deduplication); and reply chains via In-Reply-To/References (SORT and THREAD).

Value

A list with two components: messages, a list of n character vectors (the lines of each RFC 822 message); and info, a data.frame with one row per message describing the features embedded in it (from, subject, date, is_utf8_body, is_large, has_attachment, attachment_type ("csv", "png", "pdf", or NA), is_reply, and the flags – seen, flagged – that populate_sandbox will set after appending).

See Also

Other sandbox: enron_sandbox(), ingest_maildir(), populate_sandbox()

Examples

corpus <- sandbox_corpus(n = 5)
# the first synthetic message
cat(corpus$messages[[1]], sep = "\n")
# features embedded in each message
corpus$info

mRpostman documentation built on July 28, 2026, 9:08 a.m.