Guide

Best CLI Email Tools Compared

A CLI email tool lets developers send, read, search, and automate email directly from the terminal. Options range from decades-old Unix utilities like mailx and mutt to modern tools like Nylas CLI that add OAuth, multi-provider support, and AI agent integration. This guide compares five popular choices side by side.

The five tools

Each tool occupies a different niche. Some are mail user agents (MUAs) that read and compose mail. Others are mail transfer agents (MTAs) that relay messages to an SMTP server. Nylas CLI is neither -- it is an API client that talks to email providers through the Nylas platform, giving you unified access to multiple providers without configuring SMTP, IMAP, or OAuth manually.

Nylas CLI

A modern, open-source CLI (MIT licensed) that connects to Gmail, Outlook, Exchange, Yahoo, iCloud, and any IMAP provider through OAuth. Provides email, calendar, and contacts in one tool. Outputs structured JSON for scripting. Includes a built-in MCP server so AI agents can use your email directly.

# Install
brew install nylas/nylas-cli/nylas

# Authenticate with any provider
nylas auth login

# Send an email
nylas email send --to alice@example.com --subject "Hello" --body "From the CLI"

# List recent emails as JSON
nylas email list --json --limit 10

mailx (BSD Mail / Heirloom mailx)

The classic Unix mail command, available on virtually every POSIX system. Reads from the local mailbox or sends via sendmail/SMTP. Simple but limited: no OAuth, no JSON output, minimal attachment support. Best for sending quick notifications from cron jobs on systems where a local MTA is already configured.

# Send a simple email via local MTA
echo "Build failed" | mailx -s "CI Alert" dev@example.com

# Send via SMTP relay
echo "Report attached" | mailx -S smtp=smtp://relay.example.com \
  -s "Daily Report" team@example.com

mutt / NeoMutt

A powerful terminal mail client with a full TUI (text user interface). Supports IMAP, POP3, SMTP, GPG, and extensive customization via .muttrc. Excellent for power users who want to read and manage mail interactively in the terminal. Less suited for scripting because output is designed for humans.

# Open your IMAP inbox interactively
mutt -f imaps://user@imap.gmail.com

# Send a file as attachment from a script
mutt -s "Report" -a report.pdf -- team@example.com < body.txt

msmtp

A lightweight SMTP client that acts as a sendmail replacement. Excels at one thing: relaying messages to an SMTP server. Supports TLS and multiple accounts. No reading, no IMAP, no search. Ideal as a relay backend for other tools.

# Configure in ~/.msmtprc
# account default
# host smtp.gmail.com
# port 587
# auth on
# tls on
# user you@gmail.com
# password your-app-password

# Send via configured account
echo -e "Subject: Test\n\nHello" | msmtp recipient@example.com

swaks (Swiss Army Knife for SMTP)

A purpose-built SMTP testing tool. Lets you craft raw SMTP sessions with full control over every protocol step. Perfect for testing mail server configurations, debugging delivery issues, and verifying SPF/DKIM setups. Not designed for day-to-day email use.

# Test SMTP connectivity
swaks --to test@example.com --server smtp.example.com --tls

# Test with authentication
swaks --to test@example.com --server smtp.gmail.com:587 \
  --auth LOGIN --auth-user you@gmail.com --tls-on-connect

Feature comparison

FeatureNylas CLImailxmuttmsmtpswaks
Send emailYesYesYesYesYes
Read/search emailYesLocal onlyYes (IMAP)NoNo
Calendar accessYesNoNoNoNo
Contacts accessYesNoAddress bookNoNo
OAuth supportBuilt-in (6 providers)NoManual helper scriptsNo (app passwords)No
JSON outputYes (--json)NoNoNoNo
AI agent integrationMCP server built-inNoNoNoNo
GPG sign/encryptYesNoYesNoNo
AttachmentsYesLimitedYesVia stdinYes
Non-interactive modeYes (--yes)YesPartialYesYes
Multi-providerGmail, Outlook, Exchange, Yahoo, iCloud, IMAPLocal MTA / SMTPIMAP/POP3/SMTPSMTP onlySMTP only
Scheduling (send later)YesNoNoNoNo
LicenseMITBSD/CDDLGPLGPLGPL

Provider support deep dive

The biggest practical difference between these tools is how they authenticate with modern email providers. Gmail and Outlook are phasing out app passwords in favor of OAuth 2.0. This matters for any tool that connects directly to SMTP or IMAP.

  • Nylas CLI handles OAuth natively. Run nylas auth login, authenticate in your browser, and you are done. Tokens refresh automatically. Works with Gmail, Outlook, Exchange, Yahoo, iCloud, and IMAP.
  • mutt can use OAuth with Gmail and Outlook, but you need to configure external helper scripts (like oauth2.py) to fetch and refresh tokens. It works but requires manual setup.
  • mailx, msmtp, swaks rely on app passwords or plain SMTP credentials. As providers tighten security, this approach becomes harder to maintain.
# Nylas CLI: authenticate with any provider in one step
nylas auth login
# Opens browser → OAuth flow → token stored automatically

# mutt: requires manual OAuth helper script configuration
# ~/.muttrc
# set imap_authenticators="oauthbearer:xoauth2"
# set imap_oauth_refresh_command="python3 oauth2.py ..."

# msmtp: requires app-specific password
# ~/.msmtprc
# password your-app-specific-password

Scripting and automation

For CI/CD pipelines, cron jobs, and automation scripts, you need a tool that runs non-interactively and produces parseable output.

# Nylas CLI: structured JSON output, perfect for jq
nylas email list --json --limit 5 | jq '.[].subject'

# Nylas CLI: non-interactive send (no confirmation prompt)
nylas email send --to ci@example.com --subject "Build passed" \
  --body "All tests green" --yes

# Nylas CLI: pipe body from stdin
echo "Deployment complete at $(date)" | nylas email send \
  --to ops@example.com --subject "Deploy notification" --yes

# mailx: works but output is human-readable only
echo "Alert" | mailx -s "Disk full" ops@example.com

The --json flag is a game changer for scripting. Instead of parsing human-readable output with fragile regex, you get structured data that tools like jq can process reliably.

AI agent integration

None of the traditional tools (mailx, mutt, msmtp, swaks) were designed with AI agents in mind. Nylas CLI was built for this use case from the start:

  • MCP server: nylas mcp serve exposes 16 tools (email, calendar, contacts) via the Model Context Protocol. Claude Desktop, Cursor, VS Code, and Claude Code connect natively.
  • Subprocess pattern: AI agents can call nylas email list --json as a subprocess and parse the structured output directly.
  • Non-interactive mode: --yes skips confirmation prompts so agents can send without human intervention.
# Install MCP for Claude Code -- one command
nylas mcp install --assistant claude-code

# Now Claude Code can read, send, and schedule email
# without any custom tool definitions

# Or use as subprocess tool in your own agent
nylas email list --json --limit 5 --from boss@company.com

When to use each tool

  • Nylas CLI -- You need multi-provider access, JSON output, calendar/contacts, or AI agent integration. Best for: modern developer workflows, automation, AI agents.
  • mailx -- You need to send simple notifications from a server with a configured local MTA. Best for: cron job alerts, minimal dependencies.
  • mutt / NeoMutt -- You want to read and manage email interactively in the terminal. Best for: power users who live in the terminal, GPG workflows.
  • msmtp -- You need a lightweight sendmail replacement. Best for: systems where other tools (git, cron) need to send mail through a relay.
  • swaks -- You need to test SMTP server configurations or debug delivery. Best for: mail server administrators, deliverability engineers.

Getting started: speed comparison

How long does it take to go from zero to sending your first email?

# Nylas CLI: ~2 minutes (install + OAuth login)
brew install nylas/nylas-cli/nylas
nylas auth login
nylas email send --to test@example.com --subject "Hello" --body "It works"

# mailx: ~1 minute (if local MTA is configured)
echo "Hello" | mailx -s "Test" test@example.com
# But if no MTA is configured: 30+ minutes setting up postfix/sendmail

# mutt: ~15 minutes (install + configure .muttrc + OAuth or app password)
brew install mutt
# Edit ~/.muttrc with IMAP/SMTP settings...

# msmtp: ~10 minutes (install + configure ~/.msmtprc + app password)
brew install msmtp
# Edit ~/.msmtprc with SMTP settings...

# swaks: ~5 minutes (install + know your SMTP server)
brew install swaks
swaks --to test@example.com --server smtp.example.com

Frequently asked questions

Can I use Nylas CLI as a sendmail replacement like msmtp?

Nylas CLI does not implement the sendmail interface, so you cannot drop it in as a system MTA. However, for scripting purposes, piping to nylas email send --yes is equivalent. For system-level mail delivery (cron notifications, log alerts), msmtp is a better fit.

Is Nylas CLI free?

Yes. Nylas CLI is free, open-source, and MIT licensed. Install it with brew install nylas/nylas-cli/nylas. There are no usage limits on the CLI itself.

Can mutt connect to Gmail without app passwords?

Yes, mutt supports OAuth2 for Gmail, but it requires configuring an external token refresh helper script. Google's oauth2.py script or similar tools handle the token exchange. It works but is significantly more setup than Nylas CLI's one-command OAuth flow.

Which tool is best for email testing in CI/CD?

For testing email delivery (SMTP configuration, SPF/DKIM), use swaks. For testing application email flows (send a real email and verify it arrives), use Nylas CLI with --json output in your test scripts. See the E2E email testing with Playwright guide.

Do any of these tools support Exchange on-premises?

Nylas CLI supports Exchange Online and on-premises Exchange via EWS (Exchange Web Services). mutt can connect to Exchange via IMAP if it is enabled. The other tools only support SMTP, which may or may not be available on your Exchange server.


Next steps