Skip to content

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

FlagShortTypeDefaultDescriptionExample
--accountstringEmail account to usemailos delete --account value
--daysint0Delete emails older than N daysmailos delete --days value
--fromstringDelete all from sendermailos delete --from value
--subjectstringDelete all with subjectmailos delete --subject value

Advanced Options

FlagShortTypeDefaultDescriptionExample
--afterstringDelete emails after date (YYYY-MM-DD)mailos delete --after value
--beforestringDelete emails before date (YYYY-MM-DD)mailos delete --before value
--confirmboolfalseConfirm deletionmailos delete --confirm
--draftsboolfalseDelete drafts instead of regular emailsmailos delete --drafts
--idsuintsliceEmail IDs to deletemailos 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] --confirm

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

Delete all emails from a sender

bash
mailos delete --from [email protected] --confirm

Delete emails by subject

bash
mailos delete --subject "Unsubscribe" --confirm

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

Delete drafts

bash
# Delete all drafts
mailos delete --drafts --confirm

# Delete drafts from specific sender
mailos delete --drafts --from [email protected] --confirm

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

Output 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 30

Error 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 needed

Safety Best Practices

  1. Always test first: Use mailos search with the same criteria to see what would be deleted
  2. Start small: Delete a few emails first, then scale up
  3. Use specific filters: Combine multiple flags to target exactly what you want to delete
  4. 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 --confirm

Folder Support

  • Inbox: Default target for email deletion
  • Drafts: Use --drafts flag 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

  1. Check your email configuration: mailos setup
  2. Verify your email password/app password is correct
  3. Ensure IMAP access is enabled for your email provider

Connection issues

  1. Verify internet connection
  2. Check if your email provider's IMAP server is accessible
  3. Try again later if server is temporarily unavailable

Permission errors

  1. Ensure your email account has delete permissions
  2. Some corporate accounts may restrict deletion
  3. Contact your email administrator if needed

See Also

Released under the MIT License.