IM
ZH-TW
文件首頁
選單
指南

IMAP 同步信箱和訊息

將 IMAP 同步作業排入佇列並保留訊息元資料以供搜尋和讀取流。

inbox-manager client-flow

IMAP 同步信箱和訊息

目的:將 IMAP 同步作業排入佇列並保留訊息元資料以供搜尋和讀取流。

使用者介面流程

  1. 使用者選擇憑證和資料夾。
  2. UI 將郵箱同步或訊息同步排隊。
  3. UI 輪詢作業/任務的最終狀態。
  4. UI 刷新/api/accounts/:account_id/emails

客戶端庫流程

const mailboxTask = await api.provider.imap.syncMailboxes(accountId, {
  credential_id: imapCredentialId,
});
const messageTask = await api.provider.imap.syncMessages(accountId, {
  credential_id: imapCredentialId,
  folder: "INBOX",
});
await api.jobs.waitForTask(accountId, messageTask.data.task_id);
const emails = await api.emails.list(accountId, { limit: 20, offset: 0 });

HTTP/curl 流程

API_BASE_URL="https://api.inbox-manager.com"

curl -sS -X POST "${API_BASE_URL}/api/accounts/${ACCOUNT_ID}/imap/sync-mailboxes" \
  -H "authorization: Bearer ${BEARER_TOKEN}" \
  -H "content-type: application/json" \
  --data "{\"credential_id\":\"${IMAP_CREDENTIAL_ID}\"}"

curl -sS -X POST "${API_BASE_URL}/api/accounts/${ACCOUNT_ID}/imap/sync-messages" \
  -H "authorization: Bearer ${BEARER_TOKEN}" \
  -H "content-type: application/json" \
  --data "{\"credential_id\":\"${IMAP_CREDENTIAL_ID}\",\"folder\":\"INBOX\"}"

curl -sS "${API_BASE_URL}/api/accounts/${ACCOUNT_ID}/jobs?limit=20" \
  -H "authorization: Bearer ${BEARER_TOKEN}"

curl -sS "${API_BASE_URL}/api/accounts/${ACCOUNT_ID}/emails?limit=20&offset=0" \
  -H "authorization: Bearer ${BEARER_TOKEN}"

驗證腳本

  • scripts/provider_job_flow.sh