IMAP
Point the connector at any IMAP server and read folders, message headers, and bodies as SQL tables — perfect for support inboxes, receipts, and alerts.
Overview
What IMAP does
The IMAP connector exposes an email account as a queryable catalog. Folders become a table, messages become rows, and headers, flags, and parsed bodies become columns you can filter and aggregate.
It handles the awkward parts of IMAP for you: MIME decoding, attachment metadata, threading, and incremental sync by UID so repeated queries stay fast. Combine it with other connectors to, say, reconcile receipts in an inbox against transactions in your warehouse.
Highlights
- Folders, messages, and flags as SQL tables
- MIME-decoded subject, body, and attachment metadata
- Full-text search pushed down to the IMAP server
- Incremental sync by UID for fast repeat queries
- Read-only by default; OAuth or app-password auth
Attach & query
-- Attach an IMAP mailbox from the Orchard
ATTACH 'imap' AS mail (
TYPE vgi,
LOCATION 'https://orchard.query.farm/imap',
TOKEN getenv('ORCHARD_TOKEN')
);
-- Unanswered support email in the last week, by sender
SELECT from_address, count(*) AS messages
FROM mail.messages
WHERE mailbox = 'Support'
AND NOT answered
AND received > now() - INTERVAL 7 DAY
GROUP BY from_address
ORDER BY messages DESC;
Requires the VGI extension. Set ORCHARD_TOKEN after subscribing.
What you get
Tables & functions it exposes
Once attached, the connector adds these objects to your SQL session.
imap.mailboxes One row per folder with message counts.
imap.messages Headers, flags, and decoded bodies per message.
search(query) Server-side IMAP search returning matching messages.
imap_credentials Host, username, and OAuth/app-password secret.
Use cases
What teams build with IMAP
Triage a shared support inbox with SQL instead of filters.
Extract receipts or invoices and join them to accounting data.
Audit which alerting emails actually arrived, and when.
Keep exploring
Other connectors
Kafka
Streaming
Read and produce Kafka topics as SQL tables.
Row / Column Level Security
Governance
Policy-based row filtering and column masking for any catalog.
HostQuery
Federation
Federate queries across remote database hosts.
Ready to attach IMAP?
Subscribe in minutes, or talk to us about a custom connector for your stack.