Thunderbird automation

Thunderbird has experienced a remarkable revival since 2022. After years of stagnation, the Mozilla Foundation is once again actively investing in its development. The Supernova initiative (Thunderbird 115+) brought fundamental modernizations such as Rust integration for performance-critical components, a modernized UI based on Web Components, and native Exchange support via the EWS/Microsoft Graph API.


For users who use Thunderbird to manage large IMAP mailboxes with many messages and a deep folder hierarchy, immediate availability (offline synchronization) and efficient storage are important. By default, Thunderbird can experience synchronization delays, and the mbox format is known to be prone to bloat, as deleted emails are often only marked for deletion and not physically removed.

Thunderbird, with its JavaScript API, offers powerful client-side email management capabilities. Thunderbird is based on the Mozilla platform and uses XPCOM (Cross Platform Component Object Model) for its internal architecture. The JavaScript API allows direct access to mail services via the MailServices Interface. This architecture differs fundamentally from web APIs and requires specific domain knowledge.

Thunderbird stores emails locally in mbox format, initially only marking deleted messages as deleted. Without regular compaction, these files grow continuously, leading to performance degradation and the "ghost email" problem—messages that remain in the file structure but are no longer visible. The combination of IMAP synchronization and mbox maintenance can effectively prevent storage space issues and performance degradation.

The following script allows you to perform a "sweep" through all configured accounts and folders every few minutes. For each folder, it forces an offline update (downloading new emails for IMAP) and triggers a compaction process (physically removing deleted emails from the mbox file). This ensures that the local Thunderbird instance is a perfect, streamlined reflection of the server data.

76e66bbe83e88080a46f215744332e81

    There are two main methods for running this script: The Thunderbird error console (Extras > Entwickler-Werkzeuge > Fehlerkonsole or Strg+Umschalt+JThe code can be inserted and executed directly there. Alternatively, for persistent use: The extension userChromeJS, which allows any JavaScript files to be loaded when Thunderbird starts, thus offering maximum flexibility for automation.

    Some of Thunderbird's default settings are designed for convenience and would interfere with our script. Therefore, the following settings should be changed in the Thunderbird configuration (about:configThese settings can be adjusted to optimize automation and ensure smooth, aggressive synchronization and compaction. The values below are intentionally aggressive and should match your load profile.

    76e66bbe83e88080a46f215744332e81

    Microsoft has announced that Outlook Classic (Win32) will be deprecated in favor of the new Outlook for Windows. Outlook Classic will remain supported "for some" scenarios until at least 2029, but Microsoft recommends migrating much sooner. Some reports cite April 2026 as the target date for a widespread transition, with continued support until 2029. This decision has raised significant concerns in enterprise environments.

    A web-based architecture with limited offline functionality, lack of COM add-in support, no longer supporting PST files, reduced VBA macro functionality eliminating decades-old automations, performance degradation with large mailboxes, and data privacy concerns due to mandatory cloud synchronization. This development makes evaluating alternatives a strategic necessity – Thunderbird is definitely worth considering.

    Back