You want to send email from a script. Or read your inbox without leaving the terminal. Or automate calendar invites from a cron job.
The Unix ecosystem has tools for this — mailx, mutt, msmtp, swaks — but each one covers a different slice of the problem. None handles modern OAuth for Gmail or Microsoft 365 out of the box. None outputs JSON for scripting. None touches calendar or contacts.
Here's how they compare, and where Nylas CLI fits in.
The five tools
mailx (BSD Mail / Heirloom mailx)
The classic Unix mail command, standardized in POSIX.2. Available on virtually every POSIX system. Sends via local MTA or SMTP relay. Simple but limited: no OAuth, no JSON, minimal attachment support.
echo "Build failed" | mailx -s "CI Alert" dev@example.com
mutt / NeoMutt
A powerful terminal mail client with a full TUI. Supports IMAP, POP3, SMTP, GPG, and extensive .muttrc customization. Excellent for power users who want to read mail interactively. Less suited for scripting.
mutt -s "Report" -a report.pdf -- team@example.com < body.txt
msmtp
A lightweight SMTP client that acts as a sendmail replacement. Does one thing well: relay messages to an SMTP server. Supports TLS and multiple accounts. No reading, no IMAP, no search.
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 protocol control. Perfect for testing mail server configs and debugging delivery.
swaks --to test@example.com --server smtp.example.com --tls
Nylas CLI
A modern CLI that connects to Gmail, Outlook, Exchange, Yahoo, iCloud, and any IMAP provider through OAuth. Provides email, calendar, and contacts in one tool. JSON output for scripting. Built-in MCP server for AI agents.
brew install nylas/nylas-cli/nylas
nylas auth login
nylas email send --to alice@example.com --subject "Hello" --body "From the CLI"
New to it? The getting started guide takes under a minute.
Feature comparison
| Feature | mailx | mutt | msmtp | swaks | Nylas CLI |
|---|---|---|---|---|---|
| Send email | Needs MTA | Needs SMTP | Yes | Testing only | One command |
| Read inbox | Local only | Yes (TUI) | No | No | Yes |
| Search email | No | Basic | No | No | Full-text |
| Gmail OAuth2 | No | Complex setup | No | No | Built-in |
| Microsoft 365 | No | Complex setup | No | No | Built-in |
| Yahoo/iCloud | No | No | No | No | Built-in |
| JSON output | No | No | No | No | --json |
| Attachments | Limited | Yes | No | Limited | Yes |
| GPG sign/encrypt | Manual | Built-in | No | No | Built-in |
| Calendar access | No | No | No | No | Yes |
| Contacts | No | No | No | No | Yes |
| AI agent (MCP) | No | No | No | No | Built-in |
| Smart compose | No | No | No | No | AI-powered |
When to use which
Use mailx when you need to fire off a quick notification from a cron job on a system where Postfix or sendmail is already configured. It's everywhere and requires zero setup.
Use mutt when you want to read, organize, and reply to email interactively in your terminal. It's the Vim of email clients — steep learning curve, unmatched power once you know it.
Use msmtp when you need a lightweight sendmail replacement. Pair it with mutt or mailx for a complete setup. Great for systems that need to relay mail without a full MTA.
Use swaks when you're debugging SMTP delivery, testing SPF/DKIM/DMARC configurations, or verifying mail server connectivity. It's a diagnostic tool, not a daily driver. For more on email deliverability debugging, see SPF, DKIM, DMARC: Debug Email Deliverability from the Terminal.
Use Nylas CLI when you need multi-provider OAuth (Gmail, Outlook, Exchange, Yahoo, iCloud, IMAP), JSON output for scripting, calendar and contacts alongside email, or AI agent integration via MCP.
Quick examples with Nylas CLI
Send email (any provider)
nylas email send \
--to "colleague@company.com" \
--subject "Quarterly report" \
--body "Please review before Friday." \
--yes
Full guide: Send Email from the Command Line
List and search inbox
nylas email list --unread --limit 10
nylas email search "invoice" --json | jq '.[].subject'
Provider-specific guides:
Calendar management
nylas calendar list --limit 5
nylas calendar create --title "Standup" --when "tomorrow 10am" --duration 30m
Full guide: Manage Calendar from the Terminal
Give AI agents email access
nylas mcp install --assistant claude-code
One command gives Claude Code, Cursor, or Codex full email and calendar tools via MCP. Setup guide: Give Your AI Agent an Email Address
Extract OTP codes
nylas otp get
# => ✓ Found code: 847291 (copied to clipboard)
Full guide: Extract OTP Codes from Email
GPG encrypted email
nylas email send --to legal@partner.com --subject "Contract" --body "..." --sign --encrypt
Full guide: GPG Encrypted Email from the CLI
PowerShell support
All commands work in PowerShell too. Dedicated guides:
- Send Email from PowerShell
- Replace Send-MailMessage (it's deprecated)
- Read and Search Email in PowerShell
- Office 365 Email from PowerShell
Full comparison with code examples for each tool: Best CLI Email Tools Compared
Related guides:
- E2E Email Testing with Playwright
- Build an AI Email Triage Agent
- AI Agent Audit Logs
- Why the Gmail API Breaks AI Agents
- Email APIs for AI Agents Compared
- CRM Email Workflows
- Secure Email Handling for CLI
All guides: cli.nylas.com/guides
Top comments (0)