Guide
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 Senior Engineering Manager
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.
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 instead of copying multiple installers into this provider guide.
brew install nylas/nylas-cli/nylasThe 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.
nylas initIn Fastmail, create the app password at Settings → Privacy & Security → App passwords. Fastmail's app password documentation 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.
nylas email list
nylas email list --limit 25
nylas email list --unread
nylas email list --folder "Archive" --limit 10Search 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.
nylas email search "*" --from billing@example.com
nylas email search "*" --subject "invoice" --limit 10
nylas email list --limit 10 --jsonWhat 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 covers Zoho, self-hosted Dovecot, ISP accounts, and other IMAP servers. The CLI email tools comparison 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 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 — every flag and subcommand, including email list and search
- email list command — flags for limits, unread mail, folders, and all-folder listing
- email search command — query syntax examples for connected accounts
- init command — setup flags for API keys, regions, and SSO
- List IMAP emails — the same flow for non-Fastmail IMAP providers
- Best CLI email tools compared — choose between API commands, sync tools, and terminal clients
- Send email from the terminal — use the same Fastmail account for outbound mail
- Getting started — install options beyond Homebrew