Draft Management
The mailos draft command (alias for drafts) provides comprehensive draft email management with automatic synchronization to your email account's Drafts folder.
Overview
Create, manage, and send draft emails with full IMAP synchronization. Drafts are saved both locally and to your email provider's Drafts folder, ensuring they're accessible from any email client.
Basic Usage
bash
# Create a single draft interactively
mailos draft --interactive
# Create multiple drafts (alias)
mailos drafts --interactive
# List drafts from IMAP Drafts folder
mailos draft --list
# Read full draft content from IMAP
mailos draft --read
# Generate drafts with AI
mailos draft --ai "create follow-up email for meeting" --count 3
# Send all drafts
mailos send --draftsCommand-Line Flags
Basic Options
| Flag | Short | Type | Default | Description | Example |
|---|---|---|---|---|---|
--account | string | Email account to use | mailos drafts --account value | ||
--bcc | -B | []string | BCC recipients | mailos drafts --bcc value | |
--body | -b | string | Email body (Markdown supported) | mailos drafts --body value | |
--cc | -c | []string | CC recipients | mailos drafts --cc value | |
--subject | -s | string | Email subject | mailos drafts --subject value | |
--to | -t | []string | Recipient email addresses | mailos drafts --to value |
Advanced Options
| Flag | Short | Type | Default | Description | Example |
|---|---|---|---|---|---|
--ai | bool | false | Use AI to generate drafts from query | mailos drafts --ai | |
--attach | -a | []string | Attachments | mailos drafts --attach value | |
--count | -n | int | 1 | Number of drafts to generate (with AI) | mailos drafts --count value |
--data | string | Data file (CSV/JSON) for bulk draft generation | mailos drafts --data value | ||
--edit-uid | uint32 | 0 | UID of existing draft to edit/update | mailos drafts --edit-uid value | |
--file | -f | string | Read body from file | mailos drafts --file value | |
--force | bool | false | Force create draft bypassing dynamic content warnings | mailos drafts --force | |
--interactive | -i | bool | false | Interactive mode for creating drafts | mailos drafts --interactive |
--list | -l | bool | false | List drafts from IMAP Drafts folder | mailos drafts --list |
--no-signature | -S | bool | false | Don't add signature | mailos drafts --no-signature |
--plain | -P | bool | false | Send as plain text only | mailos drafts --plain |
--priority | string | normal | Email priority (high/normal/low) | mailos drafts --priority value | |
--read | -r | bool | false | Read full content of drafts from IMAP | mailos drafts --read |
--replace | []string | Replace dynamic content with KEY=VALUE pairs (e.g., --replace USER_NAME=John --replace DATE=2024-01-01) | mailos drafts --replace value | ||
--signature | string | Custom signature | mailos drafts --signature value | ||
--template | string | Use a template for draft generation | mailos drafts --template value |
Output Options
| Flag | Short | Type | Default | Description | Example |
|---|---|---|---|---|---|
--output | string | Output directory for drafts (default: ~/.email/drafts) | mailos drafts --output value |
Key Features
📮 Automatic IMAP Synchronization
- Drafts are automatically saved to your email account's Drafts folder
- Compatible with Gmail, Outlook, Yahoo, and other IMAP providers
- Drafts appear instantly in your email client
- Proper RFC 822 email format with
\DraftIMAP flag
📝 Local and Remote Storage
- Local files saved to
draft-emails/directory - Remote copies in your email provider's Drafts folder
- Dual storage provides backup and cross-device access
🎯 Smart Draft Detection
- Automatically detects the correct Drafts folder name
- Handles provider-specific folders ([Gmail]/Drafts, INBOX.Drafts, etc.)
- Creates Drafts folder if it doesn't exist
Command Options
bash
mailos draft [options]| Option | Description |
|---|---|
--list, -l | List drafts from IMAP Drafts folder |
--read, -r | Read full content of drafts from IMAP |
--interactive, -i | Create drafts interactively with prompts |
--ai | Use AI to generate drafts from a query |
--count N, -n N | Number of drafts to generate (with AI) |
--template STRING | Use a template for draft generation |
--data FILE | Data file (CSV/JSON) for bulk generation |
--output DIR | Output directory (default: "draft-emails") |
Draft File Format
Drafts are saved as Markdown files with YAML frontmatter:
markdown
---
to: [email protected]
cc: [email protected]
bcc: [email protected]
subject: Meeting Follow-up
priority: high
send_after: 2024-01-15 09:00:00
attachments:
- report.pdf
- presentation.pptx
---
Dear Team,
Following up on our meeting yesterday...
Best regards,
Your NameSending Drafts
Send All Drafts
bash
mailos send --draftsPreview Before Sending
bash
mailos send --drafts --dry-runFilter by Priority
bash
# Only send high priority drafts
mailos send --drafts --filter="priority:high"Filter by Recipient
bash
# Only send to specific domain
mailos send --drafts --filter="to:*@company.com"Additional Send Options
bash
# Confirm each draft before sending
mailos send --drafts --confirm
# Keep drafts after sending
mailos send --drafts --delete-after=false
# Log sent emails
mailos send --drafts --log-file="sent.log"Reading Drafts from IMAP
List All Drafts
bash
# Show draft headers (subject, to, date)
mailos draft --listRead Full Draft Content
bash
# Show complete draft with body content
mailos draft --readThe draft reader will:
- Connect to your email provider
- Automatically detect the Drafts folder
- Display all drafts with proper formatting
- Show flags (Draft, Seen, etc.)
- Format dates in readable format
Interactive Draft Creation
When using --interactive, you'll be prompted for:
- To: Primary recipient email address
- CC: Carbon copy recipients (optional)
- Subject: Email subject line
- Body: Email content (Markdown supported)
- Priority: high/normal/low (default: normal)
Press Enter twice after the body to finish.
AI-Powered Draft Generation
bash
# Generate drafts from natural language
mailos draft --ai "create 3 follow-up emails for recent client meetings"
# Specify number of drafts
mailos draft --ai "thank you email" --count 5Template-Based Drafts
bash
# Use a template (coming soon)
mailos draft --template=follow-up --data=contacts.csvDraft Organization
draft-emails/
├── 001-meeting-follow-up-2024-01-15-143022.md
├── 002-project-update-2024-01-15-143045.md
├── 003-thank-you-2024-01-15-143102.md
├── sent/ # Successfully sent (if --delete-after=false)
│ └── 001-meeting-follow-up-2024-01-15-143022.md
└── failed/ # Failed to send
└── 003-thank-you-2024-01-15-143102.mdIMAP Folder Detection
The system automatically detects your provider's Drafts folder:
| Provider | Common Folder Names |
|---|---|
| Gmail | [Gmail]/Drafts |
| Outlook | Drafts |
| Yahoo | Draft |
| Fastmail | INBOX.Drafts |
| Generic | Drafts, Draft |
Error Handling
- If IMAP save fails, local draft is still created
- Warning displayed but operation continues
- Drafts can still be sent using local files
Examples
Weekly Newsletter Draft
bash
# Create draft interactively
mailos draft --interactive
# Enter details:
To: [email protected]
Subject: Weekly Update - Week 3
Body:
## This Week's Highlights
- Completed project milestone
- New team member onboarded
- Client meeting scheduled
# Draft saved locally and to email accountBatch Follow-up Emails
bash
# Create multiple drafts
mailos draft --interactive
# Answer 'y' when asked "Create another draft?"
# Review all drafts
ls draft-emails/
# Send with confirmation
mailos send --drafts --confirmPriority-Based Sending
bash
# Create drafts with different priorities
mailos draft --interactive # Set priority: high
mailos draft --interactive # Set priority: normal
# Send only high priority
mailos send --drafts --filter="priority:high"
# Later, send normal priority
mailos send --drafts --filter="priority:normal"Troubleshooting
Draft Not Appearing in Email Client
- Check your email client's Drafts folder
- Refresh/sync your email client
- Verify IMAP is enabled in your email settings
IMAP Connection Failed
- Ensure app-specific password is configured
- Check IMAP is enabled for your account
- Verify network connectivity
Drafts Folder Not Found
- System will attempt to create Drafts folder
- Falls back to INBOX if creation fails
- Local draft is always created successfully
Best Practices
- Use Priority Levels: Organize drafts by importance
- Preview Before Sending: Always use
--dry-runfirst - Keep Backups: Use
--delete-after=falsefor important drafts - Batch Similar Emails: Create related drafts together
- Review IMAP Status: Check for sync confirmation messages
Related Commands
mailos send- Send individual emailsmailos template- Manage email templatesmailos interactive- Interactive email modemailos read- Read emails from inbox
See Also
- Send Command - Detailed sending options
- Template Management - Create reusable templates {/* TODO: broken link removed — target page
interactive.mddoes not exist in this repo. Restore once an Interactive Mode doc is added. */}
