Skip to content
This page was generated and translated with the assistance of AI. If you spot any inaccuracies, feel free to help improve it. Edit on GitHub

Configuration Reference ​

This page is the complete reference for all PRX-Email configuration options, environment variables, and runtime settings.

Transport Configuration ​

The EmailTransportConfig struct configures both IMAP and SMTP connections:

rust
use prx_email::plugin::{
    EmailTransportConfig, ImapConfig, SmtpConfig, AuthConfig,
    AttachmentPolicy, AttachmentStoreConfig,
};

let config = EmailTransportConfig {
    imap: ImapConfig { /* ... */ },
    smtp: SmtpConfig { /* ... */ },
    attachment_store: Some(AttachmentStoreConfig { /* ... */ }),
    attachment_policy: AttachmentPolicy::default(),
};

IMAP Settings ​

FieldTypeDefaultDescription
imap.hostString(required)IMAP server hostname
imap.portu16(required)IMAP server port (typically 993)
imap.userString(required)IMAP username
imap.auth.passwordOption<String>NonePassword for LOGIN auth
imap.auth.oauth_tokenOption<String>NoneOAuth token for XOAUTH2

SMTP Settings ​

FieldTypeDefaultDescription
smtp.hostString(required)SMTP server hostname
smtp.portu16(required)SMTP server port (465 or 587)
smtp.userString(required)SMTP username
smtp.auth.passwordOption<String>NonePassword for PLAIN/LOGIN
smtp.auth.oauth_tokenOption<String>NoneOAuth token for XOAUTH2

Validation Rules ​

  • imap.host and smtp.host must not be empty
  • imap.user and smtp.user must not be empty
  • Exactly one of password or oauth_token must be set for each protocol
  • attachment_policy.max_size_bytes must be greater than 0
  • attachment_policy.allowed_content_types must not be empty

Storage Configuration ​

StoreConfig ​

FieldTypeDefaultDescription
enable_walbooltrueEnable WAL journal mode
busy_timeout_msu645000SQLite busy timeout in milliseconds
wal_autocheckpoint_pagesi641000Pages between automatic checkpoints
synchronousSynchronousModeNormalSync mode: Full, Normal, or Off

SQLite Pragmas Applied ​

sql
PRAGMA foreign_keys = ON;
PRAGMA journal_mode = WAL;        -- when enable_wal = true
PRAGMA synchronous = NORMAL;      -- matches synchronous setting
PRAGMA wal_autocheckpoint = 1000; -- matches wal_autocheckpoint_pages

Attachment Policy ​

AttachmentPolicy ​

FieldTypeDefaultDescription
max_size_bytesusize26,214,400 (25 MiB)Maximum attachment size
allowed_content_typesHashSet<String>See belowAllowed MIME types

Default Allowed MIME Types ​

MIME TypeDescription
application/pdfPDF documents
image/jpegJPEG images
image/pngPNG images
text/plainPlain text files
application/zipZIP archives

AttachmentStoreConfig ​

FieldTypeDefaultDescription
enabledbool(required)Enable attachment persistence
dirString(required)Root directory for stored attachments

Path Safety

Attachment paths are validated against directory traversal attacks. Any path resolving outside the configured dir root is rejected, including symlink-based escapes.

Sync Runner Configuration ​

SyncRunnerConfig ​

FieldTypeDefaultDescription
max_concurrencyusize4Maximum jobs per runner tick
base_backoff_secondsi6410Initial backoff on failure
max_backoff_secondsi64300Maximum backoff (5 minutes)

Environment Variables ​

OAuth Token Management ​

VariableDescription
{PREFIX}_IMAP_OAUTH_TOKENIMAP OAuth access token
{PREFIX}_SMTP_OAUTH_TOKENSMTP OAuth access token
{PREFIX}_IMAP_OAUTH_EXPIRES_ATIMAP token expiry (Unix seconds)
{PREFIX}_SMTP_OAUTH_EXPIRES_ATSMTP token expiry (Unix seconds)

The default prefix is PRX_EMAIL. Use reload_auth_from_env("PRX_EMAIL") to load these at runtime.

WASM Plugin ​

VariableDefaultDescription
PRX_EMAIL_ENABLE_REAL_NETWORKunset (disabled)Set to 1 to enable real IMAP/SMTP from WASM context

API Limits ​

LimitValueDescription
List/search limit minimum1Minimum limit parameter
List/search limit maximum500Maximum limit parameter
Debug message truncation160 charsProvider debug messages are truncated
Message snippet length120 charsAuto-generated message snippets

Error Codes ​

CodeDescription
ValidationInput validation failure (empty fields, out-of-range limits, unknown features)
FeatureDisabledOperation blocked by feature flag
NetworkIMAP/SMTP connection or protocol error
ProviderEmail provider rejected the operation
StorageSQLite database error

Outbox Constants ​

ConstantValueDescription
Backoff base5 secondsInitial retry backoff
Backoff formula5 * 2^retriesExponential growth
Max retriesUnboundedCapped by backoff growth
Idempotency keyoutbox-{id}-{retries}Deterministic Message-ID

Feature Flags ​

FlagDescriptionRisk Level
inbox_readList and get messagesLow
inbox_searchSearch messages by queryLow
email_sendSend new emailsMedium
email_replyReply to existing emailsMedium
outbox_retryRetry failed outbox messagesLow

Logging ​

PRX-Email outputs structured logs to stderr in the format:

[prx_email][structured] {"event":"...","account":...,"folder":...,"message_id":...,"run_id":...,"error_code":...}
[prx_email][debug] context | details

Security ​

  • OAuth tokens, passwords, and API keys are never logged
  • Email addresses are redacted in debug logs (e.g., a***@example.com)
  • Provider debug messages are sanitized: authorization headers are redacted and output is truncated to 160 characters

Next Steps ​

Released under the Apache-2.0 License.