skip to content
$worker

email

v0.1.4

Email worker — SMTP send and real-time IMAP read with IDLE push (email::*).

iiiverified
60 installs0 in 7d0 today
install
$iii worker add email@0.1.4
  • macOS: arm64 · x64
  • Linux: arm64 · armv7 · x64
  • Windows: arm64 · x64 · x86

exact versions are immutable; binary and bundle artifacts are digest-pinned.

functions

8

email::accounts::list

function

List configured email accounts. Returns { accounts: [{ name, provider, from, can_send, can_read, folders }] }. Use `name` as the `account` field for email::send, email::list, email::get, email::search, email::flag, email::move, and email::attachment::get.

request
empty object
response
  • accountsobject[]required
    • can_readbooleanrequired
    • can_sendbooleanrequired
    • foldersstring[]required
    • fromstringrequired
    • namestringrequired
    • providerstringrequired

email::attachment::get

function

Stream an attachment's raw bytes from a message. Payload: { account, folder, uid, part_id }. `part_id` comes from email::get's attachments[].part_id. Bytes flow over the response channel in chunks as IMAP delivers them; no in-memory buffering. Channel closes on EOF.

request
  • accountstringrequired
  • folderstringrequired
  • part_idstringrequired
  • responseobjectrequired

    Wire-identical mirror of `iii_sdk::channels::StreamChannelRef`. The SDK type does not derive `JsonSchema`, which would block typed registration of `email::search` and `email::attachment::get`. Converted via `From` at the handler boundary so the rest of the worker keeps using the SDK type.

    • access_keystringrequired
    • channel_idstringrequired
    • directionall of
      all of (1)
      variant 1
      valuestringenum: read, write
  • uidinteger· uint32requiredmin 0
response
  • okbooleanrequired

email::flag

function

Add or remove a system flag on a message. Payload: { account, folder, uid, flag, add?=true }. `flag` is one of 'seen', 'flagged', 'answered', 'deleted', 'draft' (without the leading backslash). Marking a message 'deleted' does NOT expunge — use email::move to trash, or future email::expunge.

request
  • accountstringrequired
  • addboolean
  • flagstringrequired
  • folderstringrequired
  • uidinteger· uint32requiredmin 0
response
  • okbooleanrequired

email::get

function

Fetch a single message by UID. Payload: { account, folder, uid }. Returns { uid, message_id, from, to[], subject, date, html?, text?, attachments: [{ part_id, filename, content_type, size }] }. Use email::attachment::get with the returned part_id to stream attachment bytes.

request
  • accountstringrequired
  • folderstringrequired
  • uidinteger· uint32requiredmin 0
response
  • attachmentsobject[]required
    • content_typestringrequired
    • filenamestringrequired
    • part_idstringrequired
    • sizeinteger· uintrequiredmin 0
  • datestring
  • fromstring
  • htmlstring
  • message_idstringrequired
  • subjectstringrequired
  • textstring
  • tostring[]required
  • uidinteger· uint32requiredmin 0

email::list

function

List recent messages in a folder. Payload: { account, folder?='INBOX', limit?=50, since_uid?=<int> }. Returns { items: [{ uid, message_id, from, subject, snippet, ts, seen, flagged }], next_since_uid }. Pass next_since_uid back as since_uid to page forward without missing or duplicating messages.

request
  • accountstringrequired
  • folderstring
  • limitinteger· uint32min 0
  • since_uidinteger· uint32min 0
response
  • itemsobject[]required
    • flaggedbooleanrequired
    • fromstring
    • message_idstring
    • seenbooleanrequired
    • snippetstring
    • subjectstring
    • tsstring· date-time
    • uidinteger· uint32requiredmin 0
  • next_since_uidinteger· uint32min 0

email::move

function

Move a message to another folder. Payload: { account, folder, uid, dst_folder }. Uses RFC 6851 UID MOVE when the server supports it; falls back to COPY + STORE \Deleted otherwise. Destination folder must exist on the server.

request
  • accountstringrequired
  • dst_folderstringrequired
  • folderstringrequired
  • uidinteger· uint32requiredmin 0
response
  • methodstringrequired
  • okbooleanrequired

email::search

function

Stream search results from an account's IMAP. Payload: { account, folder?='INBOX', query }. `query` is IMAP SEARCH syntax (RFC 9051), e.g. 'FROM alice@x SINCE 1-Jan-2026' or 'UNSEEN SUBJECT "invoice"'. Returns NDJSON frames on the response channel; each frame is { uid, message_id, from, subject, snippet, ts, seen, flagged }. Channel closes when search completes. No polling — frames stream as IMAP returns matches.

request
  • accountstringrequired
  • folderstring
  • querystringrequired
  • responseobjectrequired

    Wire-identical mirror of `iii_sdk::channels::StreamChannelRef`. The SDK type does not derive `JsonSchema`, which would block typed registration of `email::search` and `email::attachment::get`. Converted via `From` at the handler boundary so the rest of the worker keeps using the SDK type.

    • access_keystringrequired
    • channel_idstringrequired
    • directionall of
      all of (1)
      variant 1
      valuestringenum: read, write
response
  • okbooleanrequired

email::send

function

Send an email via the account's SMTP transport. Payload: { account: string (key from email worker config), to: string[], cc?: string[], bcc?: string[], subject: string, html?: string, text?: string, reply_to?: string, in_reply_to?: string (Message-ID), references?: string[], attachments?: [{ filename, content_type, source: { kind: 'base64', data } }] }. Returns { message_id }. Credentials are fetched from auth-credentials under provider key `email::<account>` ({ username, password }). Provide html OR text (or both); at least one body is required.

request
  • accountstringrequired
  • attachmentsobject[]
    • content_typestringrequired
    • filenamestringrequired
    • sourceone ofrequired
      one of (1)
      variant 1
      • kindstringrequiredenum: base64
  • bccstring[]
  • ccstring[]
  • htmlstring
  • in_reply_tostring
  • referencesstring[]
  • reply_tostring
  • subjectstringrequired
  • textstring
  • tostring[]required
response
  • message_idstringrequired

triggers

1

email::new-mail

trigger

Fires when IMAP IDLE pushes a new message to a configured (account, folder). Payload: { account, folder, uid, message_id, from, subject, snippet, ts }. If the IMAP server lacks the IDLE capability, the account fails at startup (E610).

invocation
  • accountstringrequired
  • folderstring
  • handler_timeout_msinteger· uint64min 0
return
valueunknown