---
title: "IMAP API for mail, calendar and contacts · Workwae"
description: "Connect IMAP and SMTP accounts, plus CalDAV and CardDAV, through one hosted Workwae API with sync, search, send and webhooks."
url: https://workwae.com/providers/imap
---

Providers

# An IMAP API, with CalDAV and CardDAV beside it.

Any mailbox that speaks IMAP and SMTP can connect with a password or with Google or Microsoft OAuth. Calendars and contacts come from [CalDAV](https://workwae.com/glossary#caldav) and [CardDAV](https://workwae.com/glossary#carddav) on that account.

What the protocols require

## Three standards, not one vendor API.

IMAP does not include calendar or contacts, and it has no single push standard. The links are the specifications and the two large providers’ own notes.

### IMAP and SMTP

Read and search over IMAP, usually port 993 with TLS. Send over SMTP, usually port 587 with STARTTLS. [IMAP](https://www.rfc-editor.org/rfc/rfc9051) and [SMTP](https://www.rfc-editor.org/rfc/rfc5321).

### OAuth instead of a password

Gmail IMAP needs the restricted `https://mail.google.com/` scope. Microsoft IMAP and SMTP need `IMAP.AccessAsUser.All` and `SMTP.Send` on the Exchange resource, and the tenant must allow those protocols. [Gmail IMAP](https://developers.google.com/workspace/gmail/imap/imap-smtp), [Microsoft SMTP](https://learn.microsoft.com/en-us/exchange/clients-and-mobile-in-exchange-online/authenticated-client-smtp-submission).

### Change detection

Servers that offer CONDSTORE and QRESYNC can report vanished messages. Others need UID and flag comparisons. IDLE is per mailbox, not a webhook. [QRESYNC](https://www.rfc-editor.org/rfc/rfc7162).

### CalDAV and CardDAV

Calendars and address books are separate HTTP services, discovered from well-known URLs or DNS. There is no push; clients poll. [CalDAV](https://www.rfc-editor.org/rfc/rfc4791), [CardDAV](https://www.rfc-editor.org/rfc/rfc6352).

What Workwae does

## Discovery, sync and webhooks for any mailbox.

### Server discovery

Hosts are filled from a provider table, the domain autoconfig file, Mozilla ISPDB, DNS SRV, then MX. Private and loopback addresses are refused, and so are plaintext logins.

### Sync and notify

Changes use QRESYNC when the server offers it, otherwise UID and flag diffs. Where the server supports IDLE, NOTIFY or both, Workwae listens; otherwise it polls. Your app gets signed webhooks either way.

### Google and Microsoft over IMAP

Prefer the Gmail API and Graph for those accounts. IMAP remains for tenants that need it. Gmail over IMAP requires your own Google app. A Microsoft IMAP token cannot call Graph; 21Vianet mail uses this path because Graph delta is not available there.

### CalDAV and CardDAV

The same account can store CalDAV and CardDAV settings. Discovery covers iCloud, Fastmail, Yahoo calendar, GMX, Zoho, mailbox.org and Posteo, then well-known URLs. Collections are polled. There is no server-made meeting link on CalDAV. [CalDAV and CardDAV](https://workwae.com/providers/caldav-carddav).

SDK

## One connect link for IMAP.

Hosted connect asks for the mailbox and, when you enable them, calendar and contacts. Password accounts can also be created from credentials you already hold.

imap.tsimap.py

```ts
const session = await workwae.connectSessions.create({
  redirectUri: "https://app.example.com/mail/connected",
  providers: ["imap"],
  externalRef: user.id,
  options: { calendarEnabled: true, contactsEnabled: true },
});

return redirect(session.url);
```

```python
session = workwae.connect_sessions.create(
    redirect_uri="https://app.example.com/mail/connected",
    providers=["imap"],
    external_ref=user.id,
    options={"calendar_enabled": True, "contacts_enabled": True},
)

return redirect(session.url)
```

FAQ

## Questions teams ask.

**Does every IMAP account get a calendar?**

Only when CalDAV is configured for it. IMAP itself has no calendar. The same is true of contacts and CardDAV.

**Will you connect to a server on our private network?**

No. Discovery and mail connections refuse private and loopback addresses, and plaintext logins are refused. The mailbox has to be reachable on the public internet with TLS.

**Should Gmail use IMAP?**

Use the [Gmail API](https://workwae.com/providers/gmail) unless you need IMAP semantics. Gmail IMAP needs the full mail scope, which Workwae’s own Google app does not request, so it has to be your app.

**How does send work?**

Through the account’s SMTP server. Sent mail is appended to the Sent mailbox unless the server files it itself, which Gmail and Microsoft do.

Early access

## Put every IMAP mailbox on the same API.

Tell us which mail hosts your users are on.

[Request early access](https://workwae.com/early-access/) [Gmail API instead](https://workwae.com/providers/gmail)
