If your application or AI agent needs to receive email programmatically, there are three approaches. All of them work, but they differ on setup effort, delay, and how much polling they need.

Option 1: IMAP

IMAP (Internet Message Access Protocol) is the traditional way applications access email. Libraries like imaplib (Python), node-imap (Node.js), or javax.mail (Java) connect to an email server and retrieve messages.

Pros: Works with any existing email account (Gmail, Outlook, etc.)

Cons: Complex API. Google and Microsoft now require OAuth2 instead of passwords, making setup much harder. Rate limits apply. You must poll repeatedly. No push notifications. Shared inboxes cause coordination problems for concurrent systems.

Option 2: REST API Polling

# Poll every 5 seconds until an email arrives
while True:
    r = requests.get(f"{BASE}/v1/inboxes/{inbox_id}/emails", headers=headers)
    emails = r.json()["data"]
    if emails:
        process(emails[0])
        break
    time.sleep(5)

Pros: Simpler than IMAP. Works anywhere. No OAuth setup.

Cons: Each poll interval adds an average 2.5-second delay, polling burns API quota, and a process has to keep running indefinitely.

Option 3: Long-Poll API (Recommended)

# One call that blocks until email arrives
r = requests.get(
    f"{BASE}/v1/inboxes/{inbox_id}/wait?timeout=60",
    headers=headers,
    timeout=65
)
email = r.json()

Pros: Instant response when email arrives. One HTTP call instead of repeated polling. No wasted quota. Simple to use.

Cons: Connection stays open for up to the timeout duration.

Option 4: Webhooks

Configure a webhook URL and Lumbox POSTs to it the moment an email arrives.

Pros: Truly push-based. Scales to any volume. No connection held open.

Cons: Requires a public HTTPS endpoint. More complex to set up for local development or simple scripts.

Recommendation

So the choice depends on the setup. Scripts and agent workflows use long-poll, production servers with many agents use webhooks, and IMAP is only needed when you have to read from a pre-existing email account.