check
Verify configuration and connectivity.
```bash
python scripts/gmail.py check
```
This validates:
- Python dependencies are installed
- Authentication is configured
- Can connect to Gmail API
- Displays your email address and mailbox statistics
auth setup
Store OAuth 2.0 client credentials for custom OAuth flow.
```bash
python scripts/gmail.py auth setup \
--client-id YOUR_CLIENT_ID \
--client-secret YOUR_CLIENT_SECRET
```
Credentials are saved to ~/.config/agent-skills/gmail.yaml.
messages list
List messages matching a query.
```bash
# List recent messages
python scripts/gmail.py messages list
# Search for unread messages
python scripts/gmail.py messages list --query "is:unread"
# Search with max results
python scripts/gmail.py messages list --query "from:user@example.com" --max-results 20
# Output as JSON
python scripts/gmail.py messages list --query "subject:meeting" --json
```
Arguments:
--query: Gmail search query (optional)--max-results: Maximum number of results (default: 10)--json: Output as JSON
Search Query Examples:
For complete Gmail search syntax, see [gmail-queries.md](references/gmail-queries.md).
Common queries:
is:unread - Unread messagesfrom:user@example.com - Messages from sendersubject:meeting - Messages with subject keywordhas:attachment - Messages with attachmentsafter:2024/01/01 - Messages after datelabel:important - Messages with label
messages get
Get a message by ID.
```bash
# Get full message
python scripts/gmail.py messages get MESSAGE_ID
# Get minimal format
python scripts/gmail.py messages get MESSAGE_ID --format minimal
# Output as JSON
python scripts/gmail.py messages get MESSAGE_ID --json
```
Arguments:
message_id: The message ID (required)--format: Message format (full, minimal, raw, metadata) - default: full--json: Output as JSON
send
Send an email message.
```bash
# Send simple email
python scripts/gmail.py send \
--to recipient@example.com \
--subject "Hello" \
--body "This is the message body"
# Send with CC and BCC
python scripts/gmail.py send \
--to recipient@example.com \
--subject "Team Update" \
--body "Here's the update..." \
--cc team@example.com \
--bcc boss@example.com
# Output as JSON
python scripts/gmail.py send \
--to user@example.com \
--subject "Test" \
--body "Test message" \
--json
```
Arguments:
--to: Recipient email address (required)--subject: Email subject (required)--body: Email body text (required)--cc: CC recipients (comma-separated)--bcc: BCC recipients (comma-separated)--json: Output as JSON
drafts list
List draft messages.
```bash
# List drafts
python scripts/gmail.py drafts list
# List with custom max results
python scripts/gmail.py drafts list --max-results 20
# Output as JSON
python scripts/gmail.py drafts list --json
```
Arguments:
--max-results: Maximum number of results (default: 10)--json: Output as JSON
drafts create
Create a draft email.
```bash
# Create draft
python scripts/gmail.py drafts create \
--to recipient@example.com \
--subject "Draft Subject" \
--body "This is a draft message"
# Create draft with CC
python scripts/gmail.py drafts create \
--to recipient@example.com \
--subject "Meeting Notes" \
--body "Notes from today's meeting..." \
--cc team@example.com
# Output as JSON
python scripts/gmail.py drafts create \
--to user@example.com \
--subject "Test Draft" \
--body "Draft body" \
--json
```
Arguments:
--to: Recipient email address (required)--subject: Email subject (required)--body: Email body text (required)--cc: CC recipients (comma-separated)--bcc: BCC recipients (comma-separated)--json: Output as JSON
drafts send
Send a draft message.
```bash
# Send draft by ID
python scripts/gmail.py drafts send DRAFT_ID
# Output as JSON
python scripts/gmail.py drafts send DRAFT_ID --json
```
Arguments:
draft_id: The draft ID to send (required)--json: Output as JSON
labels list
List all Gmail labels.
```bash
# List labels
python scripts/gmail.py labels list
# Output as JSON
python scripts/gmail.py labels list --json
```
Arguments:
labels create
Create a new label.
```bash
# Create label
python scripts/gmail.py labels create "Project X"
# Output as JSON
python scripts/gmail.py labels create "Important" --json
```
Arguments:
name: Label name (required)--json: Output as JSON