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:

  1. Go to myaccount.google.com/apppasswords
  2. Enable 2-Step Verification if you haven't already
  3. Generate an App Password for "Mail"
  4. Run gmail-cli configure and 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

Read the full story about gmail-cli →


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.