Open Command
Open specific emails in your system's default mail application using email ID, sender, subject, or other criteria. Works cross-platform with macOS Mail, Outlook, Thunderbird, and other mail clients.
Usage
bash
mailos open [flags]Description
The open command allows you to quickly open emails in your default mail application. You can specify emails by their ID, sender, subject line, or choose from the most recent emails. The command integrates with your system's default mail client to provide a seamless email management experience.
Flags
Identification Flags
--id <uint>- Email ID to open--message-id <string>- Open email directly by Message-ID--from <string>- Open email from specific sender--subject <string>- Open email by subject (partial match)--last <int>- Open from last N emails (opens most recent)
Account Management
--account <string>- Email account to use (if different from default)
Examples
Open by Email ID
bash
# Open email with specific ID
mailos open --id 123
# Open email by Message-ID
mailos open --message-id "<[email protected]>"Open by Sender
bash
# Open most recent email from specific sender
mailos open --from [email protected]Open by Subject
bash
# Open most recent email with subject containing "Meeting"
mailos open --subject "Meeting"
# Open email with partial subject match
mailos open --subject "Invoice"Open Recent Emails
bash
# Open from last 5 emails (opens most recent)
mailos open --last 5
# Open the most recent email
mailos open --last 1Multi-Account Usage
bash
# Open email using specific account
mailos open --id 123 --account [email protected]Platform Support
macOS
- Integrates with Mail.app using AppleScript
- Searches by subject and sender for accurate email matching
- Falls back to search interface if direct email access fails
Windows
- Supports Outlook with search functionality
- Uses mailto: URLs for fallback compatibility
- Works with default mail client configuration
Linux
- Compatible with Thunderbird and other mail clients
- Uses xdg-open for system integration
- Supports standard mail client protocols
How It Works
- Authentication: Ensures you're authenticated with the email provider
- Email Search: If no ID specified, searches for emails matching criteria
- Mail Client Integration: Opens the email in your default mail application
- Cross-Platform: Uses platform-specific methods to integrate with mail clients
Search Behavior
When using search criteria (--from, --subject, --last):
- Searches through your inbox first
- Falls back to sent folder if not found in inbox
- Returns most recent match when multiple emails match
- Uses fuzzy matching for subject and sender fields
Error Handling
The command handles common scenarios:
- Email not found: Returns helpful error message
- Mail client not available: Provides fallback options
- Authentication issues: Prompts for re-authentication
- Invalid email ID: Returns clear error message
Notes
- The command requires an active internet connection for IMAP access
- Some mail clients may require additional permissions for automation
- Search results are limited to recent emails for performance
- The --last flag opens the most recent email from the specified range
Related Commands
mailos search- Advanced email search with filteringmailos read- Read email content in terminalmailos sent- View sent emails
Troubleshooting
Mail Client Not Opening
- Ensure your default mail client is properly configured
- Try opening the mail client manually first
- Check system permissions for mail client automation
Email Not Found
- Verify the email ID is correct
- Try using search criteria instead of ID
- Check if the email is in a different folder
Authentication Issues
- Run
mailos configto verify account settings - Ensure app-specific passwords are current
- Check internet connection and IMAP settings
