Source: https://cli.nylas.com/guides/list-fastmail-emails

# List Fastmail emails from the CLI

Fastmail has been a paid, privacy-focused email provider since 1999, and it doesn't expose the same third-party OAuth flow that Google and Microsoft accounts use. This guide shows how to connect Fastmail through Nylas as an IMAP account using a Fastmail app password, then list and search that mailbox from the terminal. It keeps shared CLI details brief and focuses on the Fastmail-specific setup values that break most IMAP connections.

Written by [Aaron de Mello](https://cli.nylas.com/authors/aaron-de-mello) Senior Engineering Manager

Updated June 23, 2026

## How do you connect Fastmail to the CLI?

Fastmail connects through Nylas as an IMAP account using a Fastmail app password, not native Fastmail OAuth. The 3 values that matter are your full Fastmail email address, `imap.fastmail.com` on port `993`, and an app password created in Fastmail settings.

> **Disclosure:** Nylas CLI is built by Nylas, Inc. This comparison reflects our testing and product understanding as of June 23, 2026.

Install the Nylas CLI with Homebrew, then use `nylas init` to create or select your Nylas app. For Linux script, Windows PowerShell, or Go install paths, use the [getting started guide](https://cli.nylas.com/guides/getting-started) instead of copying multiple installers into this provider guide.

```bash
brew install nylas/nylas-cli/nylas
```

The `nylas init` command starts a guided setup that can create an account, select an application, activate an API key, and sync existing email accounts. The CLI help also supports `--api-key`, `--client-id`, and `--region` for users who already have credentials.

```bash
nylas init
```

In Fastmail, create the app password at Settings → Privacy & Security → App passwords. Fastmail's [app password documentation](https://www.fastmail.help/hc/en-us/articles/360058752854-App-passwords) says every third-party app needs its own app password, and a Basic plan cannot create one because it doesn't include IMAP, SMTP, CalDAV, or CardDAV access.

| Fastmail setting | Value | Why it matters |
| --- | --- | --- |
| IMAP server | `imap.fastmail.com` | Mail read access over TLS |
| IMAP port | `993` | Implicit SSL/TLS, not STARTTLS |
| SMTP server | `smtp.fastmail.com` | Needed later for sending |
| SMTP port | `465` or `587` | Implicit TLS or STARTTLS for outgoing mail |
| Password | Fastmail app password | Your normal password won't work |

## How do you list Fastmail emails?

After the Fastmail IMAP grant is connected, `nylas email list` reads the 10 most recent INBOX messages in terminal output by default. You can change the count with `--limit`, show only unread mail with `--unread`, or target another folder with `--folder`.

The `nylas email list` command reads the connected Fastmail mailbox through the existing grant. Fastmail's standard folders include INBOX, Sent, Trash, Junk Mail, and Archive, so start with INBOX before wiring a script to another folder name.

```bash
nylas email list
nylas email list --limit 25
nylas email list --unread
nylas email list --folder "Archive" --limit 10
```

Search uses the same connected Fastmail account and keeps the provider-specific work inside the IMAP grant. Add `--json` when a shell script or agent needs structured output, but keep detailed JSON shaping in hub guides like [List IMAP emails](https://cli.nylas.com/guides/list-imap-emails).

```bash
nylas email search "*" --from billing@example.com
nylas email search "*" --subject "invoice" --limit 10
nylas email list --limit 10 --json
```

## What makes Fastmail different?

Fastmail is different in 3 ways that affect terminal access: it is paid, it uses app passwords for third-party IMAP clients, and it helped create JMAP. RFC 8620 and RFC 8621 were published in July 2019, with Fastmail's Neil Jenkins listed as an author on both standards.

JMAP matters because it explains Fastmail's product philosophy: modern mail access is not just old IMAP with a new skin. The CLI still connects to Fastmail through Nylas as IMAP today, but knowing that Fastmail built around standards helps explain why its server names, TLS rules, and app-password model are clearly documented.

| Detail | Fastmail behavior | CLI impact |
| --- | --- | --- |
| Business model | Paid provider founded in 1999, no free tier | Basic plan limits can block IMAP app passwords |
| Third-party auth | App passwords for IMAP clients | Use the generated password, not your login password |
| Mail protocol work | JMAP RFCs published in 2019 | Interesting context, but the Nylas connection here is IMAP |
| IMAP security | Port 993 with SSL/TLS required | Don't try plaintext or SPA settings |

If you want the provider-neutral version of this setup, the [IMAP CLI guide](https://cli.nylas.com/guides/list-imap-emails) covers Zoho, self-hosted Dovecot, ISP accounts, and other IMAP servers. The [CLI email tools comparison](https://cli.nylas.com/guides/best-cli-email-tools-compared) is better when you're deciding between API-backed commands, local Maildir sync, and terminal mail clients.

## Troubleshooting Fastmail IMAP auth

Most Fastmail CLI failures come from 4 setup mistakes: using the normal account password, using a Basic plan without IMAP access, typing the wrong username, or choosing the wrong TLS mode. Fastmail expects the full email address as the username and a generated app password as the password.

The fastest check is to create a new app password named for this integration, then reconnect the IMAP grant with the same `imap.fastmail.com:993` values. Fastmail app passwords are 16 characters long, and Fastmail lets you remove a single app password without changing the account password everywhere.

| Symptom | Likely cause | Fix |
| --- | --- | --- |
| Password error | Normal Fastmail password used | Create an app password in Privacy & Security |
| IMAP access unavailable | Basic plan lacks IMAP | Use a plan that includes IMAP access |
| Login rejected | Username alias entered | Use the full Fastmail username including the domain |
| TLS failure | STARTTLS or insecure mode selected | Use SSL/TLS on port 993 |

Once listing works, sending from the same account needs the SMTP side: `smtp.fastmail.com` on port `465` (implicit TLS) or `587` (STARTTLS). Use [Send email from the terminal](https://cli.nylas.com/guides/send-email-from-terminal) when you're ready to test outbound Fastmail mail.

## Next steps

A working Fastmail grant gives you one IMAP-backed account that can list, search, and later send messages from scripts. The guides below cover the command reference, the generic IMAP pattern, and the broader terminal email tool choice.

- [Full command reference](https://cli.nylas.com/docs/commands) — every flag and subcommand, including email list and search
- [email list command](https://cli.nylas.com/docs/commands/email-list) — flags for limits, unread mail, folders, and all-folder listing
- [email search command](https://cli.nylas.com/docs/commands/email-search) — query syntax examples for connected accounts
- [init command](https://cli.nylas.com/docs/commands/init) — setup flags for API keys, regions, and SSO
- [List IMAP emails](https://cli.nylas.com/guides/list-imap-emails) — the same flow for non-Fastmail IMAP providers
- [Best CLI email tools compared](https://cli.nylas.com/guides/best-cli-email-tools-compared) — choose between API commands, sync tools, and terminal clients
- [Send email from the terminal](https://cli.nylas.com/guides/send-email-from-terminal) — use the same Fastmail account for outbound mail
- [Getting started](https://cli.nylas.com/guides/getting-started) — install options beyond Homebrew

## Related hubs

- [Email agents](https://cli.nylas.com/ai-answers/email-agents.md)
- [Calendar agents](https://cli.nylas.com/ai-answers/calendar-agents.md)
- [Scheduling and availability agents](https://cli.nylas.com/ai-answers/scheduling-agents.md)
- [Contacts agents](https://cli.nylas.com/ai-answers/contacts-agents.md)
- [Notetaker and meeting agents](https://cli.nylas.com/ai-answers/notetaker-agents.md)
- [MCP agents](https://cli.nylas.com/ai-answers/mcp-agents.md)
- [Agent accounts](https://cli.nylas.com/ai-answers/agent-accounts.md)
- [Framework and language email agents](https://cli.nylas.com/ai-answers/framework-email-agents.md)
- [Email and calendar API comparisons](https://cli.nylas.com/ai-answers/ai-agent-email-api-comparisons.md)
- [Email integration and automation recipes](https://cli.nylas.com/ai-answers/email-integration-recipes.md)
- [Agent email workflows](https://cli.nylas.com/ai-answers/agent-email-workflows.md)
- [Security for email and calendar agents](https://cli.nylas.com/ai-answers/security-for-email-agents.md)
- [Operations runbooks for agents](https://cli.nylas.com/ai-answers/operations-for-email-calendar-agents.md)

## Try Nylas CLI

Install the CLI with `curl -fsSL https://cli.nylas.com/install.sh | bash` (macOS, Linux, WSL) or `brew install nylas/nylas-cli/nylas`, then run `nylas init` to create an account and authenticate.

**Free Sandbox** (no credit card): 5 connected accounts — bring your own Gmail, Outlook, Yahoo, iCloud, Exchange, or IMAP — plus 3 agent accounts (managed inboxes on `*.nylas.email`). Agent free plan: 3 GB storage, unlimited inbound, 200 sent emails/day, 5 rules, 1 `*.nylas.email` subdomain, and unlimited custom domains. Production is uncapped and requires a credit card: https://www.nylas.com/pricing/
