EmailOS Delete Command Documentation
The mailos delete command permanently removes emails or drafts from your email account.
Basic Usage
bash
mailos delete [flags]Deletes emails based on specified criteria. Requires confirmation flag for safety.
Command-Line Flags
Basic Options
| Flag | Short | Type | Default | Description | Example |
|---|---|---|---|---|---|
--account | string | Email account to use | mailos delete --account value | ||
--days | int | 0 | Delete emails older than N days | mailos delete --days value | |
--from | string | Delete all from sender | mailos delete --from value | ||
--subject | string | Delete all with subject | mailos delete --subject value |
Advanced Options
| Flag | Short | Type | Default | Description | Example |
|---|---|---|---|---|---|
--after | string | Delete emails after date (YYYY-MM-DD) | mailos delete --after value | ||
--before | string | Delete emails before date (YYYY-MM-DD) | mailos delete --before value | ||
--confirm | bool | false | Confirm deletion | mailos delete --confirm | |
--drafts | bool | false | Delete drafts instead of regular emails | mailos delete --drafts | |
--ids | uintslice | Email IDs to delete | mailos delete --ids value |
Safety Features
Confirmation Required
All delete operations require the --confirm flag to prevent accidental deletions:
bash
# This will fail with an error
mailos delete --from [email protected]
# This will work
mailos delete --from [email protected] --confirmPreview Before Deletion
The command shows what will be deleted before proceeding:
bash
mailos delete --from [email protected] --confirm
# Output:
# Found 15 email(s) to delete:
# - [Jan 2] From: [email protected] - Special Offer!
# - [Jan 3] From: [email protected] - Limited Time Deal
# ... and 13 more
# ✓ Deleted 15 email(s)Examples
Delete specific emails by ID
bash
# Get email IDs first
mailos search --from [email protected]
# Delete specific emails
mailos delete --ids 123,456,789 --confirmDelete all emails from a sender
bash
mailos delete --from [email protected] --confirmDelete emails by subject
bash
mailos delete --subject "Unsubscribe" --confirmDelete old emails
bash
# Delete emails older than 90 days
mailos delete --days 90 --confirm
# Delete emails before specific date
mailos delete --before 2024-01-01 --confirmDelete drafts
bash
# Delete all drafts
mailos delete --drafts --confirm
# Delete drafts from specific sender
mailos delete --drafts --from [email protected] --confirmCombine filters
bash
# Delete old emails from specific sender
mailos delete --from [email protected] --days 30 --confirm
# Delete emails in date range
mailos delete --after 2024-01-01 --before 2024-06-01 --confirmOutput Information
The delete command provides detailed feedback:
bash
mailos delete --from [email protected] --confirm
# Output:
# Reading emails to delete...
# Found 8 email(s) to delete:
# - [Dec 15] From: [email protected] - You've Won!
# - [Dec 16] From: [email protected] - Claim Your Prize
# - [Dec 17] From: [email protected] - Final Notice
# ... and 5 more
# ✓ Deleted 8 email(s)Getting Email IDs
Use the search command to find email IDs before deletion:
bash
# Search for emails to get IDs
mailos search --from [email protected]
mailos search --subject "promotion"
mailos search --days 30Error Handling
Common errors and solutions:
bash
# Missing confirmation
Error: please use --confirm flag to delete emails
# Solution: Add --confirm flag
# Invalid date format
Error: invalid --before date format (use YYYY-MM-DD)
# Solution: Use YYYY-MM-DD format: 2024-01-01
# No emails found
No emails found matching criteria
# This is normal - no action neededSafety Best Practices
- Always test first: Use
mailos searchwith the same criteria to see what would be deleted - Start small: Delete a few emails first, then scale up
- Use specific filters: Combine multiple flags to target exactly what you want to delete
- Backup important emails: Export critical emails before bulk deletion
Test Before Delete Workflow
bash
# 1. Test the search criteria first
mailos search --from [email protected] --days 30
# 2. Review the results, then delete with same criteria
mailos delete --from [email protected] --days 30 --confirmFolder Support
- Inbox: Default target for email deletion
- Drafts: Use
--draftsflag to target draft folder - Gmail: Automatically handles Gmail's special folder structure
Notes
- Deletions are permanent and cannot be undone
- Large bulk deletions may take several minutes
- The command processes up to 1000 emails per operation
- Deleted emails are moved to trash/deleted items folder (behavior depends on email provider)
- Some email providers may have additional retention policies
Troubleshooting
Authentication errors
- Check your email configuration:
mailos setup - Verify your email password/app password is correct
- Ensure IMAP access is enabled for your email provider
Connection issues
- Verify internet connection
- Check if your email provider's IMAP server is accessible
- Try again later if server is temporarily unavailable
Permission errors
- Ensure your email account has delete permissions
- Some corporate accounts may restrict deletion
- Contact your email administrator if needed
See Also
mailos search- Find emails before deletionmailos read- Read specific emails before deciding to deletemailos drafts- Manage draft emails
