Gmail CLI Tool
A zero-dependency Python tool that lets you send emails from the command line using Gmail SMTP. Install with a single command, configure once, and send emails from scripts, automation workflows, or AI agents.
Quick Install
macOS / Linux
curl -sSL https://colinknapp.com/tools/gmail-cli/install.sh | bash
Windows PowerShell
iwr -useb https://colinknapp.com/tools/gmail-cli/install.ps1 | iex
Setup: Gmail App Password
Gmail requires an App Password for SMTP access (your regular password won't work with 2FA enabled). Here's how to set one up:
- Go to myaccount.google.com/apppasswords
- Enable 2-Step Verification if you haven't already
- Generate an App Password for "Mail"
- Run
gmail-cli configureand enter your Gmail address and the App Password
gmail-cli configure
Usage Examples
Simple Email
gmail-cli send recipient@example.com -s "Hello" -b "Hi there!"
Email with Attachments
gmail-cli send recipient@example.com \
-s "Weekly Report" \
-b "Please find the report attached." \
-a report.pdf \
-a data.csv
Pipe Content from stdin
cat logfile.txt | gmail-cli send admin@example.com -s "Server Logs"
Test Connection
gmail-cli test
Command Reference
| Command | Description |
|---|---|
gmail-cli configure |
Set up Gmail credentials (interactive) |
gmail-cli configure --email x --password y |
Set credentials non-interactively |
gmail-cli send TO -s SUBJ -b BODY |
Send an email |
gmail-cli send TO -s SUBJ -a FILE |
Send with attachment(s) |
gmail-cli test |
Test SMTP connection |
gmail-cli config |
Show current configuration |
Features
- Zero dependencies: Uses only Python 3 standard library
- Cross-platform: Works on macOS, Linux, and Windows
- Secure: Uses Gmail App Passwords and TLS encryption
- Simple: One-line installation, easy configuration
- Flexible: Supports attachments, stdin input, and automation
Accessibility: This website is designed and developed to meet WCAG 2.1 Level AAA standards, ensuring the highest level of accessibility for all users. Features include high contrast ratios, keyboard navigation, screen reader compatibility, and responsive design. The site supports both light and dark modes with automatic system preference detection.