IMAP email

Mail metadata, including Gmail with app passwords.

Who can see it Not yet
Works with Any IMAP server · Gmail app passwords
Set up in console

Scan attachments in any IMAP mailbox, including Gmail with an app password.

What it scans

Content Read by default? How to change it
Attachment names (messages that have attachments) Yes Always on
Attachment files of supported types Yes scan_attachments
Subject line, with From, To and Date No (opt-in) Also scan subject lines (slower)
Message bodies Never Use Microsoft 365 or Google Workspace
  • Folders open read-only, and reads use PEEK, so mail is never marked as read.
  • Sender and recipient address headers alone do not produce contact-information findings.
  • PDF, DOCX, XLSX, PPTX and other full-support formats use the whole-file parser up to max_parse_bytes.
  • Supported text files are read in full up to the agent's full-read limit.
  • Skipped with a recorded reason: unsupported strings-only or binary types, and nested message/rfc822 attachments.

What you need

  • An agent that can reach the IMAP server.
  • A server with a trusted TLS certificate.
  • A username and password the server accepts. Use a dedicated read-only mailbox account or a separately revocable app password.

OAuth-only IMAP accounts cannot use this connector: it signs in with a password.

Step 1: Enable access for the mailbox

  1. Enable IMAP over TLS (usually port 993).
  2. Create a scan account with read access to the chosen folders.
  3. Make sure INBOX is selectable. The agent probes INBOX even when you scan a different folder prefix.

Step 2: Add your connection

  1. Open Connections → Add connection → IMAP mailbox.
  2. Enter the host and port, and choose TLS (IMAPS) or STARTTLS.
  3. Select your agent and choose Local credential catalog.
  4. Set an optional Folder prefix and save.

Put the username in the secret file, not in the console config.

Step 3: Prepare credentials and scan

  1. Save the JSON and catalog from Secret file on the agent, using the read-only mount in Agent credentials.
  2. Wait for present.
  3. Queue a scan from Scans.

You should see the scan complete, then results in Coverage and Findings.

Connection settings table

Console field Example Required or optional
Connection name Accounts mailbox Required; unique in workspace
Type IMAP mailbox (imap) Required
Host imap.gmail.com Required; hostname, no URL
Port 993 Optional in config; enter 993 for IMAPS, 143 for STARTTLS
IMAP encryption imaps or starttls Optional; default imaps; none refuses login
Folder prefix INBOX Optional; blank scans every readable folder
Agent Mail agent Required; same workspace
Credential mode Local credential catalog Required
Credential name IMAP_MAIL Required; uppercase alias
Exclude patterns (View/edit) INBOX* Optional; one glob per line
Enabled (connection row) Enabled Disable to stop new scans

Secret file

Save /srv/myrikeep/secrets/IMAP_MAIL. Both values must be nonempty strings:

json
{"username": "[email protected]", "password": "<MAILBOX_OR_APP_PASSWORD>"}

Merge this catalog entry:

json
{"version": 1, "credentials": {"IMAP_MAIL": {"type": "imap", "source": {"kind": "file_json", "path": "/run/secrets/IMAP_MAIL"}}}}
  • Follow Agent credentials for file modes and the directory mount.
  • A revoked app password can still report present until a scan tries to log in.

Scope, exclusions and schedules

Folder prefix is a case-sensitive starts-with match: INBOX includes INBOX and INBOX/Receipts. Prefer it over exclude globs to choose mail folders. There is no "received after" field for IMAP.

Exclude globs match these pseudo-paths:

Pseudo-path What it is When it exists
INBOX 123.eml Subject and header block Only when subject-line scanning is on
INBOX 123.txt Attachment names Every message that has attachments
INBOX 123/2-report.pdf An attachment file (MIME section index, sanitized filename) Every supported attachment

Messages without attachments produce no pseudo-files unless subject-line scanning is on.

Glob Effect
*.pdf Skips PDF downloads and classification; attachment names are still classified
INBOX* Skips every file in folders that begin with INBOX
*.txt Skips attachment-name metadata and TXT attachment files
  • Attachment locators look like imap://<folder>/<uid>#att=<section> (for example #att=2.1). Existing #headers and #attachments locators are unchanged.
  • See Getting started for schedules.

Large mailboxes and Gmail limits

Tune each connection in Connections → View/edit → Advanced: IMAP attachments and throttling. Leave a number blank for its automatic default; an explicit 0 keeps its documented meaning.

Config setting Safe range Default Gmail preset Effect
scan_attachments boolean true true Read supported attachment files; false keeps attachment names only.
attachment_max_mb 1–100 10 10 Per-file MiB cap, checked on BODYSTRUCTURE encoded octets before download.
max_attachments_per_message 1–500 100 100 Attachment parts per message; extra parts are skipped with reasons.
daily_download_budget_mb 0–2,400 0 (none) 1,500 Daily download budget per mailbox, decimal MB, spent by every FETCH response, metadata included.
scan_subject_lines boolean false false Also classify each Subject with From/To/Date (Also scan subject lines (slower)).
fetch_batch_size 1–500 50 100 Messages per metadata FETCH; a message's pseudo-files share it.
pause_between_batches_ms 0–60,000 0 0 Minimum ms from one FETCH batch finishing to the next starting.
max_messages_per_minute 0–10,000 0 (unlimited) 0 (unlimited) Rolling-minute pacing: metadata counts per UID; each attachment fetch (retries too) counts as one.
reconnect_attempts 0–10 3 5 Retries after the first FETCH attempt; 0 disables retries.
socket_timeout_seconds 5–300 60 60 Timeout for connection and socket operations.

Gmail preset

  • Applies to gmail.com and googlemail.com and their subdomains, such as imap.gmail.com, because Google limits daily IMAP downloads per account.
  • These are conservative scanner defaults, not Google's published quotas or a guarantee against throttling.
  • Explicit settings override the preset one by one.

Automatic pacing

  • By default the pause and message ceiling are 0: the connector does not pace itself.
  • After the server first pushes back (BYE, a throttled or "too many" response, an aborted session or a socket error), values you did not set rise to a 250 ms batch pause and a 1,500-message ceiling for the rest of the scan.
  • Values you set apply from the start and are never raised.

Daily download budget

  • When the remaining budget is smaller than an attachment's encoded size, the attachment is skipped with the reason daily download budget reached; the next scan will pick it up.
  • Metadata is still fetched, so attachment names still classify.
  • The budget recovers on a rolling 24-hour window: a new scan starts with the limit minus what this connection's finished scans downloaded in the last 24 hours.
  • 0 means no budget.
Agent versions for these settings

The settings live in non-secret connection config. They reach agents that advertise these capabilities:

Settings Agent capability
Batch, pause, pacing, reconnect, timeout imap-throttle-v1
scan_attachments, attachment_max_mb, max_attachments_per_message imap-attachments-v1
daily_download_budget_mb, scan_subject_lines imap-budget-v1

Older agents receive only the settings they understand, and omit these options until upgraded. New agents use the defaults above when an older server omits the keys.

How the scanner reads a mailbox
  • It selects a folder once per session and fetches header fields, BODYSTRUCTURE and INTERNALDATE together, one batch at a time.
  • Unless subject-line scanning is on, only messages with attachments are enumerated:
  • Gmail connections and servers advertising X-GM-EXT-1 search X-GM-RAW "has:attachment", and fall back to listing every message when the server refuses.
  • On every server, the cached BODYSTRUCTURE filters out messages without attachments.
  • It caches only the current batch's responses and uses them for both header and attachment-name reads. Attachment enumeration uses the same cached BODYSTRUCTURE.
  • It never requests message bodies: no BODY[], BODY[TEXT] or body text sections.
  • Supported files under the encoded-size cap are fetched one at a time with UID FETCH <uid> (BODY.PEEK[<section>]), decoded (base64, quoted-printable, or unencoded 7bit/8bit/binary) and passed to the normal runner. Only one decoded attachment is cached at a time.
  • The size gate uses encoded sizes, so it is conservative: base64 files near the decoded cap can be skipped.
  • Attachment fetches share batch pauses, rate pacing, socket timeout and reconnect/backoff with metadata.
Reconnects, retries and read errors
  • On BYE, an aborted session, socket or TLS errors, timeouts or throttling responses, the agent closes the broken socket and waits with exponential backoff and jitter (capped at 60 seconds). It then logs in again, reselects the folder and retries the same UID batch or attachment section.
  • If retries run out, that batch or file is recorded as a read error. The next operation starts on a fresh connection.
  • Every pseudo-file still gets at most one classification observation. Long pacing waits renew the lease.
  • Scans shows read-error totals and classes, reconnects and throttle waits.
  • Agent warnings report only the error class, folder and UID: the first 20 errors, then every 500th. Subjects, addresses and server error text are excluded.
  • A scan with read errors has incomplete coverage, even if it completes.

"Who can see it" support

Sharing checks are not available for this source yet.

  • Not assessed: forwarding rules, mailbox delegates and message recipient access.
  • Age review uses INTERNALDATE (received time), not the sender's Date header.

See Who can see it.

Troubleshooting

Symptom or state Fix
unknown Check heartbeat, assignment and current connection revision.
missing / credential_missing Match catalog alias/type and check the secret mount.
Invalid / credential_config_invalid Use exactly username/password strings; check owner, mode and no symlinks.
present JSON resolved; provider login has not been tested yet.
source_error / cannot open IMAP session Inspect local agent diagnostics; check host, TLS certificate, port and whether password login is supported.
LOGIN refused on unencrypted IMAP connection Set imaps on 993 or starttls on the server's STARTTLS port; do not use none.
Authentication failed / access denied Reissue the app password; check username and server policy. For Exchange Online use M365.
Cannot select INBOX / unselectable folder Grant read/select rights; check folder names and INBOX access.
[THROTTLED] / Too many / repeated reconnects Lower the message ceiling, raise the batch pause, and avoid concurrent scans of one mailbox. Retry after provider limits clear.
attachments_skipped_budget / daily download budget reached The mailbox's daily budget was spent; a later scan picks them up as the 24-hour window frees budget. Raise daily_download_budget_mb (Gmail preset 1,500) or wait.
Read errors / abort / TimeoutError / SSLError Check Scans totals and agent warnings for folder/UID and error class. Check connectivity and TLS; raise the timeout within range. Exhausted retries affect one batch; later batches reconnect.
Exposure upload rejected / invalid_locator Upgrade server and agent together; current releases accept nested folders such as [Gmail]/All Mail. Rejection logs include a short content-free reason code.
MAX_MESSAGES Narrow the Folder prefix; enumeration stops at 100,000 messages.
Paused / Migration paused / Disabled Resume the agent, assign and save a valid connection, or enable it.
signin_required Only personal drives use OAuth sign-in. IMAP needs a server that accepts password login.
Expected mail is missing Review Coverage and the account's folder permissions.

Limits

Limit Value
Attachment file size 10 MiB encoded by default (attachment_max_mb)
Attachments per message 100 parts by default (max_attachments_per_message)
Metadata read per part 64 KiB
Messages enumerated 100,000 (MAX_MESSAGES)

Never done: reading message bodies, sending, deleting, marking as read, changing folders, server or mailbox discovery.

Skipped: larger files, unsupported types, embedded messages, and unselectable or newline-named folders.

Always kept: attachment names stay classified even when attachment scanning is off or a file is skipped. Headers are classified only when subject-line scanning is on.

Scan stats: attachments_scanned, attachments_skipped_too_large, attachments_skipped_type, attachments_skipped_nested, attachments_skipped_limit and attachments_skipped_budget.