Skip to content

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 --drafts

Command-Line Flags ​

Basic Options ​

FlagShortTypeDefaultDescriptionExample
--accountstringEmail account to usemailos drafts --account value
--bcc-B[]stringBCC recipientsmailos drafts --bcc value
--body-bstringEmail body (Markdown supported)mailos drafts --body value
--cc-c[]stringCC recipientsmailos drafts --cc value
--subject-sstringEmail subjectmailos drafts --subject value
--to-t[]stringRecipient email addressesmailos drafts --to value

Advanced Options ​

FlagShortTypeDefaultDescriptionExample
--aiboolfalseUse AI to generate drafts from querymailos drafts --ai
--attach-a[]stringAttachmentsmailos drafts --attach value
--count-nint1Number of drafts to generate (with AI)mailos drafts --count value
--datastringData file (CSV/JSON) for bulk draft generationmailos drafts --data value
--edit-uiduint320UID of existing draft to edit/updatemailos drafts --edit-uid value
--file-fstringRead body from filemailos drafts --file value
--forceboolfalseForce create draft bypassing dynamic content warningsmailos drafts --force
--interactive-iboolfalseInteractive mode for creating draftsmailos drafts --interactive
--list-lboolfalseList drafts from IMAP Drafts foldermailos drafts --list
--no-signature-SboolfalseDon't add signaturemailos drafts --no-signature
--plain-PboolfalseSend as plain text onlymailos drafts --plain
--prioritystringnormalEmail priority (high/normal/low)mailos drafts --priority value
--read-rboolfalseRead full content of drafts from IMAPmailos drafts --read
--replace[]stringReplace dynamic content with KEY=VALUE pairs (e.g., --replace USER_NAME=John --replace DATE=2024-01-01)mailos drafts --replace value
--signaturestringCustom signaturemailos drafts --signature value
--templatestringUse a template for draft generationmailos drafts --template value

Output Options ​

FlagShortTypeDefaultDescriptionExample
--outputstringOutput 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 \Draft IMAP 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]
OptionDescription
--list, -lList drafts from IMAP Drafts folder
--read, -rRead full content of drafts from IMAP
--interactive, -iCreate drafts interactively with prompts
--aiUse AI to generate drafts from a query
--count N, -n NNumber of drafts to generate (with AI)
--template STRINGUse a template for draft generation
--data FILEData file (CSV/JSON) for bulk generation
--output DIROutput directory (default: "draft-emails")

Draft File Format ​

Drafts are saved as Markdown files with YAML frontmatter:

markdown
---
to: recipient@example.com
cc: cc@example.com
bcc: bcc@example.com
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 Name

Sending Drafts ​

Send All Drafts ​

bash
mailos send --drafts

Preview Before Sending ​

bash
mailos send --drafts --dry-run

Filter 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 --list

Read Full Draft Content ​

bash
# Show complete draft with body content
mailos draft --read

The 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:

  1. To: Primary recipient email address
  2. CC: Carbon copy recipients (optional)
  3. Subject: Email subject line
  4. Body: Email content (Markdown supported)
  5. 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 5

Template-Based Drafts ​

bash
# Use a template (coming soon)
mailos draft --template=follow-up --data=contacts.csv

Draft 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.md

IMAP Folder Detection ​

The system automatically detects your provider's Drafts folder:

ProviderCommon Folder Names
Gmail[Gmail]/Drafts
OutlookDrafts
YahooDraft
FastmailINBOX.Drafts
GenericDrafts, 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: team@company.com
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 account

Batch 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 --confirm

Priority-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 ​

  1. Use Priority Levels: Organize drafts by importance
  2. Preview Before Sending: Always use --dry-run first
  3. Keep Backups: Use --delete-after=false for important drafts
  4. Batch Similar Emails: Create related drafts together
  5. Review IMAP Status: Check for sync confirmation messages
  • mailos send - Send individual emails
  • mailos template - Manage email templates
  • mailos interactive - Interactive email mode
  • mailos read - Read emails from inbox

See Also ​

  • Send Command - Detailed sending options
  • Template Management - Create reusable templates {/* TODO: broken link removed — target page interactive.md does not exist in this repo. Restore once an Interactive Mode doc is added. */}

Released under the MIT License.