Changes up to Thunderbird 78 Beta

Thunderbird 74 Beta

legacy API

  • The legacy API has been removed.

accounts API & folders API

  • The MailFolder object gained a subFolders property. From now on the accounts API functions will return a hierarchy of folders instead of a flat list. If you still need a flat list you should traverse the folder hierarchy:

    browser.accounts.list().then(accounts => {
      let arrayOfFolders = [];
    
      function traverse(folders) {
        if (!folders) {
          return;
        }
        for (let f of folders) {
          arrayOfFolders.push(f);
          traverse(f.subFolders);
        }
      }
    
      for (let account of accounts) {
        traverse(account.folders);
      }
      return arrayOfFolders;
    });
    

    This example code works with both the current API in 68 and the new version in 74 (which will be backported to 68 after some time in beta).

compose API

  • The compose API gained two new functions and an event. The getComposeDetails and setComposeDetails functions let you retrieve or change the recipients and subject of a message being composed. More details will be added later. The onBeforeSend event is fired when a message is about to be sent. At this point your extension can prevent sending or change the same details as in the new functions.

messages API

  • The query function can now query by tags.

  • The MessageHeader object now has junk properties: junkScore is an integer score from 0 (not spam) to 100 (spam). junk shows whether or not that score is greater than the junk threshold.

Thunderbird 75 Beta

action APIs

  • The onClick event of the action APIs now has information about the active tab and the click event.

    This brings the events into line with browser WebExtensions. For messageDisplayAction, this is a change of behavior – previously the ID of the active tab was passed as the first argument.

    This change was uplifted to 74 beta 2.

compose API

  • The onBeforeSend event now has information about the active tab.

    This change was uplifted to 74 beta 2.

  • The compose API functions can now handle the message body.

    All responses from getComposeDetails calls and onBeforeSend events now return the message body. How you handle this depends on the composition mode (plain text or HTML). For plain text composition mode, the isPlainText field is set to true and plainTextBody should be used. For HTML composition, isPlainText is set to false and body should be used.

    The body field is a string. You should parse this to an HTML document before modifying it, and serialise the document back to a string before calling setComposeDetails. Here’s a sample extension.

messages API

  • A new event was added: onNewMailReceived.

    Your extension can now be notified of incoming mail. This is based on the MailServices.mfn.msgsClassified notification.

Thunderbird 76 Beta

accounts API

  • Thunderbird 76 introduces the MailIdentity type for interacting with mail identities. Like the rest of the accounts API, it is mostly read-only as we believe that configuration of identities should only happen using the built-in UI.

  • The MailAccount type now contains a list of identities associated with that account. The default identity is listed first and other identities are in no particular order.

  • The accounts API now has a setDefaultIdentity(accountId, identityId) function.

compose API

  • The ComposeDetails type now has an identityId field for getting or setting the identity associated with a message being composed.

mailTabs/messageDisplay

  • For consistency with other APIs and with browser WebExtensions (ie. those used in Firefox, etc.), some events that passed a numeric tab ID to listeners now pass an object representing the tab instead. This change is not backwards-compatible.

    The affected events are:

messages API

  • The accountsRead permission is now required for all functions that accept a MailFolder argument. The permission was already required to obtain a MailFolder anyway, so this change should not break extensions.

experiment APIs

  • For extensions with the addressBooks permission, a new addressBookManager object is available to WebExtensions experiment implementations. The addressBookManager provides the following functions to help you interact with the addressBooks API, contacts API and mailingLists API:

    • findAddressBookById, findContactById, findMailingListById to help you find “real” address book objects (nsIAbCard, nsIAbDirectory) for the IDs provided by the addressBooks API. Note that there is active development in the address book and these interfaces will be changing in the near term without public announcement.

    • convert to turn “real” objects back into API-friendly objects.

    For more information on these functions see the source code of the addressBooks APIs.

Thunderbird 77 Beta

compose API

tabs API

composeScripts API

  • Content script functions can now operate on a compose window “tab” in the same way they do on a content tab in Thunderbird or Firefox. (Despite the fact they don’t have tabs, compose windows have one tab object under the tabs API.) This requires the compose permission.

    Here are some basic examples. See the MDN documentation for a more in-depth explanation.

    // Where tabId is the id of a compose window tab:
    
    browser.tabs.executeScript(tabId, {
      code: `document.body.textContent = "Hey look, the script ran!";`,
    });
    
    browser.tabs.executeScript(tabId, {
      file: "compose.js",
    });
    
    browser.tabs.insertCSS(tabId, {
      code: "body { background-color: red; }",
    });
    
    browser.tabs.insertCSS(tabId, {
      file: "compose.css",
    });
    
    browser.tabs.removeCSS(tabId, {
      code: "body { background-color: red; }",
    });
    
    browser.tabs.removeCSS(tabId, {
      file: "compose.css",
    });
    
  • Scripts can also be registered to run automatically on composition window “tabs”, using the new composeScripts API. Again, this works just like the contentScripts API:

    let registeredScripts = await browser.composeScripts.register({
      css: [
        // Any number of code or file objects could be listed here.
        { code: "body { background-color: red; }" },
        { file: "compose.css" },
      ],
      js: [
        // Any number of code or file objects could be listed here.
        { code: `document.body.textContent = "Hey look, the script ran!";` },
        { file: "compose.js" },
      ],
    });
    

    Added code will run immediately and CSS will be immediately applied to already-open composition windows, and any new composition windows.

    The returned value, registeredScripts in this example, is an object with which you can unregister the code/CSS:

    await registeredScripts.unregister();
    

Warning

This functionality has the ability to completely destroy every message being composed, with no way to undo it. Be careful!

Note

Javascript or CSS applied by these methods is not sent with the message. This is not a way to decorate messages or make them interactive.

Thunderbird 78 Beta

compose API

identity API