Skip to content

This is the multi-page printable view of this section.

Return to the regular view of this page

Accounts & Autodetection

Create, list, update and delete mail accounts, and detect provider settings.

An account stores the IMAP and SMTP settings plus the encrypted password. Pigeon supports any standard IMAP/SMTP provider.

The account object

{
  "id": 1,
  "name": "Personal",
  "email": "someone@qq.com",
  "username": "someone@qq.com",
  "imapHost": "imap.qq.com",
  "imapPort": 993,
  "imapSecurity": "tls",
  "smtpHost": "smtp.qq.com",
  "smtpPort": 465,
  "smtpSecurity": "tls",
  "sentMailbox": "Sent",
  "createdAt": 1764550000,
  "unread": 3
}
Field Description
id Account ID used in other endpoints
name Display name (defaults to the part of the email before @)
email Mail address
username IMAP/SMTP login (defaults to the email address)
imapHost, imapPort, imapSecurity Incoming server; security is tls, starttls or none
smtpHost, smtpPort, smtpSecurity Outgoing server; same security values
sentMailbox Mailbox that receives sent copies (default Sent)
createdAt Unix seconds
unread Total unread messages across cached mailboxes

Passwords are never returned by any endpoint. They are encrypted at rest with AES-256-GCM; see Security.

List accounts

curl http://127.0.0.1:8787/api/accounts

Returns an array of account objects, each including the aggregated unread count.

Create an account

POST /api/accounts

curl -X POST http://127.0.0.1:8787/api/accounts \
  -H 'Content-Type: application/json' \
  -d '{
    "email": "someone@qq.com",
    "password": "app-password",
    "name": "Personal",
    "imapHost": "imap.qq.com", "imapPort": 993, "imapSecurity": "tls",
    "smtpHost": "smtp.qq.com", "smtpPort": 465, "smtpSecurity": "tls"
  }'

Required fields are email and password plus imapHost and smtpHost. Defaults fill in the rest:

  • name defaults to the part of the email before @, username defaults to email
  • imapPort/smtpPort default to 993/465
  • imapSecurity/smtpSecurity default to tls
  • sentMailbox defaults to Sent (it is updated automatically when sync finds a mailbox flagged \Sent)

On success the response is 201 with the stored account (no password). Validation rejects malformed email addresses, missing hosts, ports outside 1–65535 and security values other than tls, starttls, none.

Creating an account does not contact the mail server. Call sync to verify the credentials and fetch mailboxes.

Update an account

PUT /api/accounts/{id} replaces the account settings using the same body as creation. Omit password to keep the existing one:

curl -X PUT http://127.0.0.1:8787/api/accounts/1 \
  -H 'Content-Type: application/json' \
  -d '{
    "email": "someone@qq.com",
    "name": "Work",
    "imapHost": "imap.qq.com", "imapPort": 993, "imapSecurity": "tls",
    "smtpHost": "smtp.qq.com", "smtpPort": 465, "smtpSecurity": "tls"
  }'

Returns the saved account. Sending a non-empty password re-encrypts and replaces it.

Update the display name or password

PATCH /api/accounts/{id} updates the display name name and/or the stored password and leaves every other field untouched:

curl -X PATCH http://127.0.0.1:8787/api/accounts/1 \
  -H 'Content-Type: application/json' \
  -d '{"name": "Work"}'

curl -X PATCH http://127.0.0.1:8787/api/accounts/1 \
  -H 'Content-Type: application/json' \
  -d '{"password": "new-app-password"}'

Send at least one of name and password. Both are trimmed and must not be empty; an unknown account returns 404. In the web UI under Settings → Accounts you can edit each account’s display name; rotate its password in the Security tab under Settings — the app syncs right after saving to verify the new credential.

Delete an account

DELETE /api/accounts/{id} returns 204. Mailboxes and cached messages of the account are deleted with it; the mail on the server is untouched.

Detect provider settings

GET /api/detect?email={address} finds IMAP/SMTP settings before you create the account:

curl 'http://127.0.0.1:8787/api/detect?email=someone@gmail.com'
{
  "provider": "Google Mail",
  "imap": {"host": "imap.gmail.com", "port": 993, "security": "tls", "username": "someone@gmail.com"},
  "smtp": {"host": "smtp.gmail.com", "port": 465, "security": "tls", "username": "someone@gmail.com"},
  "helpUrl": "https://support.google.com/mail/answer/7126229",
  "source": "domain"
}
Field Description
provider Provider name from the database, or the domain
imap, smtp Host, port, security and login username
helpUrl Provider help page, when known
enableUrl Page explaining how to enable IMAP, when known
source How the result was found: domain, mx or guess

Detection resolves in three steps:

  1. Thunderbird ISPDB — a provider entry for the email domain
  2. MX records — map known mail exchangers to provider entries
  3. Guess — imap.<domain> / smtp.<domain> on ports 993/465 with TLS

The endpoint performs DNS lookups for the MX step and can take a moment for unknown domains. An invalid address returns 400.

Gmail requires two-step verification and an app-specific password. QQ Mail, 163 and several other Chinese providers require enabling IMAP in the provider’s web settings and using an app-specific password instead of the login password.