Account Configuration
Account variables follow the patternMAIL_IMAP_<ACCOUNT>_<KEY>. The server discovers accounts by scanning for MAIL_IMAP_*_HOST variables.
Required Per Account
IMAP server hostnameExamples:
imap.gmail.com, outlook.office365.com, imap.fastmail.comUsername for authentication (typically email address)Examples:
[email protected], [email protected]Password for authentication
Optional Per Account
IMAP server portStandard IMAPS port: 993 (implicit TLS)Validation: Must be a valid
u16 (1-65535)Whether to use TLS encryptionCurrently enforced to
true. Only implicit TLS (IMAPS) is supported.Accepted values (case-insensitive):- Truthy:
1,true,yes,y,on - Falsy:
0,false,no,n,off
Global Server Configuration
These variables apply server-wide to all accounts and operations.Write Operations
Enable write operations (copy, move, delete, flag updates)Affects tools:
imap_update_message_flagsimap_copy_messageimap_move_messageimap_delete_message
- Truthy:
1,true,yes,y,on - Falsy:
0,false,no,n,off
Connection Timeouts
TCP connection timeout in millisecondsDefault: 30,000 ms (30 seconds)When to increase:
- High-latency networks
- Slow TLS handshake on constrained systems
- Network congestion issues
u64IMAP server greeting timeout in millisecondsDefault: 15,000 ms (15 seconds)When to increase:
- Overloaded IMAP servers
- Slow authentication backends
- Geographically distant servers
u64Socket I/O timeout in milliseconds (idle, read, write)Default: 300,000 ms (5 minutes)When to increase:
- Processing large mailboxes
- Slow message retrieval
- Complex search operations
- Need faster failure detection
- Implementing custom retry logic
u64Cursor Pagination
Time-to-live for search cursors in secondsDefault: 600 seconds (10 minutes)Trade-offs:
- Shorter TTL: Less memory usage, more frequent re-searches needed
- Longer TTL: Better UX for slow workflows, higher memory usage
u64Maximum number of cursors to retain (LRU eviction when exceeded)Default: 512 entriesTrade-offs:
- Lower limit: Less memory usage, cursors may expire sooner
- Higher limit: Supports more concurrent searches, higher memory usage
usizeEnvironment Variable Priority
Variables are loaded in the following order:-
Required per account - Must be set for each discovered account:
MAIL_IMAP_<ACCOUNT>_HOSTMAIL_IMAP_<ACCOUNT>_USERMAIL_IMAP_<ACCOUNT>_PASS
-
Optional per account - Use defaults if not set:
MAIL_IMAP_<ACCOUNT>_PORT(default: 993)MAIL_IMAP_<ACCOUNT>_SECURE(default: true)
-
Global server-wide - Apply to all operations:
MAIL_IMAP_WRITE_ENABLED(default: false)MAIL_IMAP_CONNECT_TIMEOUT_MS(default: 30000)MAIL_IMAP_GREETING_TIMEOUT_MS(default: 15000)MAIL_IMAP_SOCKET_TIMEOUT_MS(default: 300000)MAIL_IMAP_CURSOR_TTL_SECONDS(default: 600)MAIL_IMAP_CURSOR_MAX_ENTRIES(default: 512)
Loading from .env Files
The server automatically loads environment variables from.env files using dotenvy:
.env
Docker Configuration
When running in Docker, pass environment variables using--env-file or -e flags:
File-based env loading (
--env-file) takes precedence over -e flags in Docker.Validation and Error Handling
Boolean Parsing
Boolean environment variables accept flexible values (case-insensitive): Truthy:1, true, yes, y, on
Falsy: 0, false, no, n, off
Unrecognized values result in an error:
Numeric Parsing
Numeric variables must be valid integers within the type’s range:Missing Required Variables
Non-Unicode Values
Viewing Current Configuration
Run the server with--help to see discovered accounts and current configuration:
- Discovered account sections
- Current environment variable values (passwords redacted)
- Global policy defaults
- Write gate policy status
Passwords and secret-like keys (
*_PASS, *_TOKEN, *_SECRET) are automatically redacted in help output.