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

VerifiedCLI 3.1.24 · Fastmail (IMAP) · last tested 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.

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/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.

nylas init

In 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 settingValueWhy it matters
IMAP serverimap.fastmail.comMail read access over TLS
IMAP port993Implicit SSL/TLS, not STARTTLS
SMTP serversmtp.fastmail.comNeeded later for sending
SMTP port465 or 587Implicit TLS or STARTTLS for outgoing mail
PasswordFastmail app passwordYour 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 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.

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.

DetailFastmail behaviorCLI impact
Business modelPaid provider founded in 1999, no free tierBasic plan limits can block IMAP app passwords
Third-party authApp passwords for IMAP clientsUse the generated password, not your login password
Mail protocol workJMAP RFCs published in 2019Interesting context, but the Nylas connection here is IMAP
IMAP securityPort 993 with SSL/TLS requiredDon'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.

SymptomLikely causeFix
Password errorNormal Fastmail password usedCreate an app password in Privacy & Security
IMAP access unavailableBasic plan lacks IMAPUse a plan that includes IMAP access
Login rejectedUsername alias enteredUse the full Fastmail username including the domain
TLS failureSTARTTLS or insecure mode selectedUse 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.