DEV Community

Qasim Muhammad
Qasim Muhammad

Posted on • Originally published at cli.nylas.com

Send Email from the Command Line — No SMTP, No Sendmail, No Postfix

Every CLI email tool has the same problem: SMTP configuration. mail needs Postfix. mutt needs credentials in a dotfile. msmtp handles sending but not reading. None support OAuth2 for Gmail or Microsoft 365 out of the box.

Nylas CLI bypasses all of this. Authenticate once, then send email from Linux, macOS, or Windows with one command. Works with Gmail, Outlook, Exchange, Yahoo, iCloud, and IMAP.

Install

# macOS / Linux
brew install nylas/nylas-cli/nylas

# Or shell script (macOS / Linux / WSL)
curl -fsSL https://cli.nylas.com/install.sh | bash

# Windows PowerShell
irm https://cli.nylas.com/install.ps1 | iex
Enter fullscreen mode Exit fullscreen mode

Authenticate

Sign up at dashboard-v3.nylas.com, create an app, connect your mailbox, grab your API key:

nylas auth config
# Paste your API key

nylas auth whoami
# => Authenticated as you@company.com (Google Workspace)
Enter fullscreen mode Exit fullscreen mode

Send an email

nylas email send \
  --to "colleague@company.com" \
  --subject "Quarterly report" \
  --body "Please review the Q4 numbers before Friday."

# Skip confirmation prompt
nylas email send --to user@example.com --subject "Quick note" --body "..." --yes

# CC and BCC
nylas email send \
  --to alice@team.com \
  --cc bob@team.com \
  --bcc manager@team.com \
  --subject "Sprint update" \
  --body "All tasks on track."
Enter fullscreen mode Exit fullscreen mode

Read and search your inbox

# List recent emails
nylas email list --limit 10

# Only unread
nylas email list --unread

# Search by keyword
nylas email search "invoice" --limit 5

# Read a specific message
nylas email read msg_abc123
Enter fullscreen mode Exit fullscreen mode

Schedule emails for later

# Send in 2 hours
nylas email send --to team@company.com --subject "Reminder" --body "..." --schedule 2h

# Send tomorrow morning
nylas email send --to team@company.com --subject "Standup" --body "..." --schedule "tomorrow 9am"
Enter fullscreen mode Exit fullscreen mode

GPG sign and encrypt

# Sign with your key
nylas email send --to legal@partner.com --subject "Contract" --body "..." --sign

# Encrypt with recipient's public key
nylas email send --to legal@partner.com --subject "Contract" --body "..." --encrypt

# Both
nylas email send --to legal@partner.com --subject "Contract" --body "..." --sign --encrypt
Enter fullscreen mode Exit fullscreen mode

Full GPG guide: GPG Encrypted Email from the CLI

AI-powered smart compose

# Generate a draft from a prompt
nylas email smart-compose --prompt "Thank them for the meeting and confirm next steps"

# Reply to a specific message
nylas email smart-compose --message-id msg_abc123 --prompt "Accept the invitation politely"
Enter fullscreen mode Exit fullscreen mode

Scripting with JSON output

Every command supports --json for piping into jq or other tools:

# Unread count
nylas email list --unread --json | jq length

# Extract senders from recent messages
nylas email list --limit 20 --json | jq -r '.[].from[0].email'

# Bulk send from CSV
while IFS=, read -r email name; do
  nylas email send \
    --to "$email" \
    --subject "Hello $name" \
    --body "Your account is ready." \
    --yes
  sleep 2
done < contacts.csv
Enter fullscreen mode Exit fullscreen mode

How it compares

Feature mail / mailx mutt Nylas CLI
Send email Needs MTA Needs SMTP One command
Read inbox Local only Yes Yes
Gmail OAuth2 No Complex Built-in
Microsoft 365 No Complex Built-in
GPG sign/encrypt Manual Built-in Built-in
Calendar access No No Yes
JSON output No No --json
AI compose No No Yes
MCP server No No Built-in

Give AI agents email access

The CLI includes a built-in MCP server. One command gives Claude Code, Cursor, or Codex CLI full email and calendar tools:

nylas mcp install --assistant claude-code
Enter fullscreen mode Exit fullscreen mode

Full setup: Give Your AI Coding Agent an Email Address


Full guide with tracking, attachments, and scheduling examples: Send Email from the Command Line

More guides: cli.nylas.com/guides

Top comments (0)