Guide

How to Send Email from the Terminal

Most command-line email tools either require you to set up a local SMTP relay or only work with a single provider. Nylas CLI connects to Gmail, Outlook, and IMAP through one unified interface -- no sendmail, no Postfix, no provider-specific configuration.

The problem with existing tools

If you have ever tried to send email from a Linux terminal, you have probably run into this: mail and mailx need a working MTA. mutt needs SMTP credentials hard-coded in a dotfile. msmtp works but only handles sending -- no reading, no search, no calendar. And none of them handle OAuth2 for Gmail or Microsoft 365.

The Nylas CLI solves this by talking directly to the Nylas API, which handles OAuth, provider abstraction, and connection management behind the scenes. You authenticate once, then every command works across every provider.

1. Install

# macOS / Linux (Homebrew)
brew install nylas-cli/tap/nylas

# Or build from source (requires Go 1.23+)
go install github.com/nylas/cli@latest

2. Authenticate your mailbox

Head to dashboard-v3.nylas.com, create an application, and connect your mailbox. Then grab your API key and run:

nylas auth config
# Paste your API key when prompted

# Verify it works
nylas auth whoami
# => Authenticated as you@company.com (Google Workspace)

3. Send an email

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

# Skip the 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."
# 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

# Read the raw MIME source
nylas email read msg_abc123 --mime

5. 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"

# Send on a specific date
nylas email send --to client@example.com --subject "Follow-up" --body "..." --schedule "2026-03-01 14:30"

6. Track opens and clicks

nylas email send \
  --to prospect@company.com \
  --subject "Proposal attached" \
  --body "Here is our proposal for Q2." \
  --track-opens \
  --track-links \
  --track-label "q2-outreach"

# Tracking events are delivered via webhooks:
nylas webhook create \
  --url https://your-server.com/hooks \
  --triggers message.opened,message.link_clicked

7. Sign and encrypt with GPG

No extra tools needed. If you have GPG installed, the CLI signs and encrypts natively using RFC 3156 PGP/MIME:

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

# Encrypt with recipient's public key (auto-fetched from keyservers)
nylas email send --to legal@partner.com --subject "Contract" --body "..." --encrypt

# Both (recommended for maximum security)
nylas email send --to legal@partner.com --subject "Contract" --body "..." --sign --encrypt

# Decrypt and verify a received message
nylas email read msg_xyz789 --decrypt --verify

See the full GPG encrypted email guide for key management, troubleshooting, and multi-recipient encryption.

8. AI-powered smart compose

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

# Generate a reply to a specific message
nylas email smart-compose --message-id msg_abc123 --prompt "Accept the invitation politely"

# AI inbox analysis
nylas email ai analyze --unread
# => Summary, categories, action items, urgency levels

9. Scripting and automation

Every command supports --json output, so you can pipe it into jq, your agent, or any other tool:

# Morning inbox summary script
#!/bin/bash
echo "=== Inbox Summary ==="
unread=$(nylas email list --unread --json | jq length)
echo "Unread: $unread"

# Urgent check
nylas email list --unread --json \
  | jq '[.[] | select(.subject | test("urgent|asap"; "i"))]' \
  | jq 'length' \
  | xargs -I{} echo "Urgent: {}"

# Bulk send from a 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

10. Pipe to AI agents

The CLI is designed for composability. Pipe JSON output to any agent running in your terminal:

# Agent triages your inbox
nylas email list --unread --json | agent triage --rules ./inbox-rules.yml

# Agent drafts a reply, CLI sends it
agent draft --context msg_a1f2 | nylas email send --to sarah@team.io

# Start the built-in MCP server for Claude, Cursor, or VS Code
nylas mcp install --assistant claude-code

See the full AI agent email access guide for MCP setup and tool configuration.


How it compares

Featuremail / mailxmuttNylas CLI
Send emailYes (needs MTA)Yes (needs SMTP)Yes (one command)
Read inboxLocal onlyYesYes
Gmail OAuth2NoComplexBuilt-in
Microsoft 365NoComplexBuilt-in
GPG sign/encryptManualBuilt-inBuilt-in
Calendar accessNoNoYes
JSON outputNoNoYes (--json)
AI composeNoNoYes
MCP serverNoNoBuilt-in

Next steps