readEmails (IMAP)
Source: src/workflows/shared/actions/imap.ts. Fetches recent message envelopes via imapflow, then applies optional filters (from/subject substrings, unseen-only, optional since-date) before returning trimmed rows for the orchestrator.
Project environment variables
Credentials are read from your project's Environment variables page (/p/<slug>/environment). They are snapshotted into record.envwhen the run starts — not from the Flowman deployment's .env file.
IMAP_HOST— server hostname (required)IMAP_PORT— usually993(default if unset or invalid)IMAP_USER/IMAP_PASSWORD(required)IMAP_TLS— optional; stringtrue/falseor1(defaults to TLS on when unset)
Usage
The first argument is always record so mailbox and filter knobs can branch on typed record.input.
typescript
import { readEmails } from "@/workflows/shared/actions";
const { emails } = await readEmails({
record,
stepKey: "inbox1",
name: "Read recent mail",
mailbox: typeof record.input.mailbox === "string" ? record.input.mailbox : "INBOX",
filter: {
fromContains: typeof record.input.from === "string" ? record.input.from : undefined,
subjectContains:
typeof record.input.subjectHint === "string" ? record.input.subjectHint : undefined,
unseenOnly: true,
},
limit: 25,
});