Overview
Write operations are disabled by default to protect against accidental mailbox modifications. This safety gate requires explicit opt-in to enable copy, move, delete, and flag update operations.Enabling Write Operations
Set the following environment variable to enable write operations:Affected Tools
WhenMAIL_IMAP_WRITE_ENABLED=false (default), the following tools return errors:
imap_update_message_flags
Add or remove IMAP flags (\Seen, \Flagged, custom flags). Requires:MAIL_IMAP_WRITE_ENABLED=true
imap_copy_message
Copy message to another mailbox (IMAPCOPY command).
Requires: MAIL_IMAP_WRITE_ENABLED=true
imap_move_message
Move message to another mailbox (IMAPMOVE or COPY + delete).
Requires: MAIL_IMAP_WRITE_ENABLED=true
imap_delete_message
Permanently delete a message (IMAPSTORE + EXPUNGE).
Requires:
MAIL_IMAP_WRITE_ENABLED=true- AND explicit
confirm=trueparameter
Error Behavior
When write operations are disabled, tools return the following error:Example Error Response
Read-Only Operations
The following tools are always enabled regardless of the write gate setting:imap_list_mailboxes- List all mailboxesimap_search_messages- Search messages with filtersimap_read_message- Read message contentimap_get_message_source- Fetch raw message sourceimap_page_forward- Pagination (next page)imap_page_backward- Pagination (previous page)
Delete Confirmation Requirement
Theimap_delete_message tool has an additional safety mechanism beyond the write gate:
Two-Level Protection
- Write gate:
MAIL_IMAP_WRITE_ENABLED=truemust be set - Explicit confirmation:
confirm=truemust be in the request
Without Confirmation
With Confirmation
The
confirm parameter must be the literal boolean true, not a string or other truthy value.Security Considerations
Why Disabled by Default?
Write operations are disabled by default because:- Prevents accidental modifications - LLMs can make mistakes
- Reduces attack surface - Read-only access is inherently safer
- Explicit opt-in - Forces conscious decision to enable writes
- Audit trail - Clear indication of write capability in configuration
When to Enable?
Enable write operations when you need:- Automated email filing and organization
- Flag management for workflow automation
- Email cleanup and archival operations
- Moving messages between mailboxes programmatically
When to Keep Disabled?
Keep write operations disabled when:- Only reading email content for analysis
- Searching and extracting information
- Building read-only integrations
- Minimizing risk of accidental changes
Best Practices
- Start read-only: Begin with writes disabled and enable only when needed
- Separate accounts: Use different accounts for read-only vs read-write operations
- Test first: Test write operations in a non-production account first
- Monitor operations: Review write operation logs regularly
- Disable when done: Disable writes after completing batch operations
Environment-Specific Configuration
Development
.env.development
Production Read-Only
.env.production
Production with Writes
.env.production
Troubleshooting
Error: write tools are disabled
MAIL_IMAP_WRITE_ENABLED=true in your environment variables or .env file.
Delete requires explicit confirm=true
"confirm": true to your imap_delete_message request payload.
Write enabled but still getting errors
-
Verify environment variable is set:
-
Check boolean value is recognized (must be:
1,true,yes,y,on) - Restart the server after changing environment variables
-
For Docker, ensure variable is passed correctly:
Implementation Details
The write gate is implemented insrc/server.rs via the require_write_enabled() function, which is called at the beginning of each write operation tool handler: