compose

This message composition window API first appeared in Thunderbird 67 (see bug 1503423).

Permissions

compose

Read and modify your email messages as you compose and send them

compose.save

Save composed email messages as drafts or templates

compose.send

Send composed email messages on your behalf

Functions

beginNew([messageId], [details])

Open a new message compose window.

Note: The compose format can be set by details.isPlainText or by specifying only one of details.body or details.plainTextBody. Otherwise the default compose format of the selected identity is used.

Note: Specifying details.body and details.plainTextBody without also specifying details.isPlainText threw an exception in Thunderbird up to version 97. Since Thunderbird 98, this combination creates a compose window with the compose format of the selected identity, using the matching details.body or details.plainTextBody value.

Note: If no identity is specified, this function is using the default identity and not the identity of the referenced message.

Parameters

[messageId]

(integer)

– [Added in TB 84, backported to TB 78.7.0]

If specified, the message or template to edit as a new message.

[details]

Return type (Promise)

Tab

– [Added in TB 77]

beginReply(messageId, [replyType], [details])

Open a new message compose window replying to a given message.

Note: The compose format can be set by details.isPlainText or by specifying only one of details.body or details.plainTextBody. Otherwise the default compose format of the selected identity is used.

Note: Specifying details.body and details.plainTextBody without also specifying details.isPlainText threw an exception in Thunderbird up to version 97. Since Thunderbird 98, this combination creates a compose window with the compose format of the selected identity, using the matching details.body or details.plainTextBody value.

Note: If no identity is specified, this function is using the default identity and not the identity of the referenced message.

Parameters

messageId

(integer)

The message to reply to, as retrieved using other APIs.

[replyType]

(string)

Supported values:

replyToSender

replyToList

replyToAll

[details]

– [Added in TB 76]

Return type (Promise)

Tab

– [Added in TB 77]

beginForward(messageId, [forwardType], [details])

Open a new message compose window forwarding a given message.

Note: The compose format can be set by details.isPlainText or by specifying only one of details.body or details.plainTextBody. Otherwise the default compose format of the selected identity is used.

Note: Specifying details.body and details.plainTextBody without also specifying details.isPlainText threw an exception in Thunderbird up to version 97. Since Thunderbird 98, this combination creates a compose window with the compose format of the selected identity, using the matching details.body or details.plainTextBody value.

Note: If no identity is specified, this function is using the default identity and not the identity of the referenced message.

Parameters

messageId

(integer)

The message to forward, as retrieved using other APIs.

[forwardType]

(string)

Supported values:

forwardInline

forwardAsAttachment

[details]

Return type (Promise)

Tab

– [Added in TB 77]

getComposeDetails(tabId)

– [Added in TB 74]

Fetches the current state of a compose window. Currently only a limited amount of information is available, more will be added in later versions.

Parameters

tabId

(integer)

Return type (Promise)

Required permissions

  • compose

setComposeDetails(tabId, details)

– [Added in TB 74]

Updates the compose window. Only fields that are to be changed should be specified. Currently only a limited amount of information can be set, more will be added in later versions.

Note: The compose format of an existing compose window cannot be changed. Since Thunderbird 98, setting conflicting values for details.body, details.plainTextBody or details.isPlaintext no longer throw an exception, instead the compose window chooses the matching details.body or details.plainTextBody value and ignores the other.

Parameters

tabId

(integer)

details

Required permissions

  • compose

getActiveDictionaries(tabId)

– [Added in TB 102]

Returns a ComposeDictionaries object, listing all installed dictionaries, including the information whether they are currently enabled or not.

Parameters

tabId

(integer)

Required permissions

  • compose

setActiveDictionaries(tabId, activeDictionaries)

– [Added in TB 102]

Updates the active dictionaries. Throws if the activeDictionaries array contains unknown or invalid language identifiers.

Parameters

tabId

(integer)

activeDictionaries

(array of string)

Required permissions

  • compose

listAttachments(tabId)

– [Added in TB 78]

Lists all of the attachments of the message being composed in the specified tab.

Parameters

tabId

(integer)

Return type (Promise)

Required permissions

  • compose

getAttachmentFile(id)

– [Added in TB 98]

Gets the content of a ComposeAttachment as a DOM File object.

Parameters

id

(integer)

The unique identifier for the attachment.

Return type (Promise)

addAttachment(tabId, attachment)

– [Added in TB 78]

Adds an attachment to the message being composed in the specified tab.

Parameters

tabId

(integer)

Return type (Promise)

Required permissions

  • compose

updateAttachment(tabId, attachmentId, attachment)

– [Added in TB 78]

Updates the name and/or the content of an attachment in the message being composed in the specified tab. If the specified attachment is a cloud file attachment and the associated provider failed to update the attachment, the function will throw an ExtensionError.

Parameters

tabId

(integer)

attachmentId

(integer)

attachment

Return type (Promise)

Required permissions

  • compose

removeAttachment(tabId, attachmentId)

– [Added in TB 78]

Removes an attachment from the message being composed in the specified tab.

Parameters

tabId

(integer)

attachmentId

(integer)

Required permissions

  • compose

sendMessage(tabId, [options])

– [Added in TB 90]

Sends the message currently being composed. If the send mode is not specified or set to default, the message will be send directly if the user is online and placed in the users outbox otherwise. The returned Promise fulfills once the message has been successfully sent or placed in the user’s outbox. Throws when the send process has been aborted by the user, by an onBeforeSend event or if there has been an error while sending the message to the outgoing mail server.

Parameters

tabId

(integer)

[options]

(object)

mode

(string)

Supported values:

default

sendNow

sendLater

Return type (Promise)

object

– [Added in TB 102]

messages

(array of MessageHeader)

Copies of the sent message. The number of created copies depends on the applied file carbon copy configuration (fcc).

mode

(string)

The used send mode.

Supported values:

sendNow

sendLater

[headerMessageId]

(string)

The header messageId of the outgoing message. Only included for actually sent messages.

Required permissions

  • compose.send

saveMessage(tabId, [options])

– [Added in TB 102]

Saves the message currently being composed as a draft or as a template. If the save mode is not specified, the message will be saved as a draft. The returned Promise fulfills once the message has been successfully saved.

Parameters

tabId

(integer)

[options]

(object)

mode

(string)

Supported values:

draft

template

Return type (Promise)

object

messages

(array of MessageHeader)

The saved message(s). The number of saved messages depends on the applied file carbon copy configuration (fcc).

mode

(string)

The used save mode.

Supported values:

draft

template

Required permissions

  • compose.save

getComposeState(tabId)

– [Added in TB 90]

Returns information about the current state of the message composer.

Parameters

tabId

(integer)

Return type (Promise)

Events

onBeforeSend

– [Added in TB 74]

Fired when a message is about to be sent from the compose window. This is a user input event handler. For asynchronous listeners some restrictions apply.

Parameters for onBeforeSend.addListener(listener)

listener(tab, details)

A function that will be called when this event occurs.

Parameters passed to the listener function

tab

(Tab)

– [Added in TB 74.0b2]

details

The current state of the compose window. This is functionally the same as calling the getComposeDetails(tabId) function.

Expected return value of the listener function

object

[cancel]

(boolean)

Cancels the send.

[details]

Updates the compose window. This is functionally the same as calling the setComposeDetails(tabId, details) function.

Required permissions

  • compose

onAttachmentAdded

– [Added in TB 78]

Fired when an attachment is added to a message being composed.

Parameters for onAttachmentAdded.addListener(listener)

listener(tab, attachment)

A function that will be called when this event occurs.

Parameters passed to the listener function

tab

(Tab)

attachment

Required permissions

  • compose

onAttachmentRemoved

– [Added in TB 78]

Fired when an attachment is removed from a message being composed.

Parameters for onAttachmentRemoved.addListener(listener)

listener(tab, attachmentId)

A function that will be called when this event occurs.

Parameters passed to the listener function

tab

(Tab)

attachmentId

(integer)

Required permissions

  • compose

onIdentityChanged

– [Added in TB 78.0b2]

Fired when the user changes the identity that will be used to send a message being composed.

Parameters for onIdentityChanged.addListener(listener)

listener(tab, identityId)

A function that will be called when this event occurs.

Parameters passed to the listener function

tab

(Tab)

identityId

(string)

Required permissions

  • accountsRead

onComposeStateChanged

– [Added in TB 90]

Fired when the state of the message composer changed.

Parameters for onComposeStateChanged.addListener(listener)

listener(tab, state)

A function that will be called when this event occurs.

Parameters passed to the listener function

tab

(Tab)

state

onActiveDictionariesChanged

– [Added in TB 102]

Fired when one or more dictionaries have been activated or deactivated.

Parameters for onActiveDictionariesChanged.addListener(listener)

listener(tab, dictionaries)

A function that will be called when this event occurs.

Parameters passed to the listener function

tab

(Tab)

dictionaries

Types

ComposeAttachment

– [Added in TB 78]

Represents an attachment in a message being composed.

object

getFile()

(function) Deprecated.

Use getAttachmentFile(id) instead, for example in a backward-compatible drop-in wrapper function.

id

(integer)

A unique identifier for this attachment.

[name]

(string)

The name of this attachment, as displayed to the user.

[size]

(integer)

– [Added in TB 83, backported to TB 78.5.0]

The size in bytes of this attachment. Read-only.

ComposeDetails

Used by various functions to represent the state of a message being composed. Note that functions using this type may have a partial implementation.

object

[additionalFccFolder]

(MailFolder or string)

– [Added in TB 102]

An additional fcc folder which can be selected while composing the message, "" if not used.

[attachVCard]

(boolean)

– [Added in TB 102]

Wether or not the vCard of the used identity will be attached to the message during send. Note: If the value has not been modified, selecting a different identity will load the default value of the new identity.

[attachments]

– [Added in TB 82, backported to TB 78.4.0]

Only used in the begin* functions. Attachments to add to the message.

[body]

(string)

The HTML content of the message.

[customHeaders]

(array of CustomHeader)

– [Added in TB 100]

Array of custom headers. Headers will be returned in Http-Header-Case (a.k.a. Train-Case). Set an empty array to clear all custom headers.

[deliveryFormat]

(string)

– [Added in TB 102]

Defines the mime format of the sent message (ignored on plain text messages). Defaults to auto, which will send html messages as plain text, if they do not include any formatting, and as both otherwise (a multipart/mixed message).

Supported values:

auto

plaintext

html

both

[deliveryStatusNotification]

(boolean)

– [Added in TB 102]

Let the sender know when the recipient’s server received the message. Not supported by all servers.

[followupTo]

– [Added in TB 74]

[from]

– [Added in TB 88]

Caution: Setting a value for from does not change the used identity, it overrides the FROM header. Many email servers do not accept emails where the FROM header does not match the sender identity. Must be set to exactly one valid email address.

[identityId]

(string)

– [Added in TB 76]

The ID of an identity from the accounts API. The settings from the identity will be used in the composed message. If replyTo is also specified, the replyTo property of the identity is overridden. The permission accountsRead is required to include the identityId.

[isPlainText]

(boolean)

– [Added in TB 75]

Whether the message is an HTML message or a plain text message.

[newsgroups]

(string or array of string)

– [Added in TB 74]

[overrideDefaultFcc]

(boolean)

– [Added in TB 102]

Indicates whether the default fcc setting (defined by the used identity) is being overridden for this message. Setting false will clear the override. Setting true will throw an exception, if overrideDefaultFccFolder is not set as well.

[overrideDefaultFccFolder]

(MailFolder or string)

– [Added in TB 102]

This value overrides the default fcc setting (defined by the used identity) for this message only. Either a MailFolder specifying the folder for the copy of the sent message, or "" to not save a copy at all.

[plainTextBody]

(string)

– [Added in TB 75]

The plain text content of the message.

[priority]

(string)

– [Added in TB 102]

The priority of the message.

Supported values:

lowest

low

normal

high

highest

[relatedMessageId]

(integer)

– [Added in TB 95]

The id of the original message (in case of draft, template, forward or reply). Read-only. Is null in all other cases or if the original message was opened from file.

[replyTo]

[returnReceipt]

(boolean)

– [Added in TB 102]

Add the Disposition-Notification-To header to the message to requests the recipients email client to send a reply once the message has been received. Recipient server may strip the header and the recipient might ignore the request.

[subject]

(string)

[type]

(string)

– [Added in TB 88]

Read-only. The type of the message being composed, depending on how the compose window was opened by the user.

Supported values:

draft

new

redirect

– [Added in TB 90]

reply

forward

ComposeDictionaries

– [Added in TB 102]

Object with language identifiers of all installed dictionaries as keys (for example en-US) and a boolean value, indicating whether that dictionary is enabled for spellchecking or not.

object

ComposeRecipient

string

A name and email address in the format “Name <email@example.com>”, or just an email address.

OR

object

id

(string)

The ID of a contact or mailing list from the contacts and mailingLists APIs.

type

(string)

Which sort of object this ID is for.

Supported values:

contact

mailingList

ComposeRecipientList

– [Added in TB 74]

OR

array of ComposeRecipient

ComposeState

– [Added in TB 90]

Represent the state of the message composer.

object

canSendLater

(boolean)

The message can be send later.

canSendNow

(boolean)

The message can be send now.

CustomHeader

A custom header definition.

object

name

(string)

Name of a custom header, must have a X- prefix.

value

(string)

FileAttachment

Object used to add, update or rename an attachment in a message being composed.

object

[file]

(File)

The new content for the attachment.

[name]

(string)

The new name for the attachment, as displayed to the user. If not specified, the name of the provided file object is used.