messengerUtilities API

The messengerUtilities API provides helpful methods for working with messages and emails.

Permissions

The following permissions influence the behavior of the API. Depending on which permissions are requested, additional methods might be available, or certain data may be included in responses.

Hint

Request permissions only when needed. Unnecessary requests may result in rejection during ATN review.

addressBook

addressBook

Functions

convertToPlainText(body, [options])

– [Added in TB 137]

Converts the provided body to readable plain text, without tags and leading/trailing whitespace.

Parameters

body

body

(string)

The to-be-converted body.

options

[options]

(object, optional)

flowed

[flowed]

(boolean, optional)

The converted plain text will be wrapped to lines not longer than 72 characters and use format flowed, as defined by RFC 2646.

Return type (Promise)

_returns

string

decodeMimeHeader(headerName, headerValue, [isMailBoxHeader])

– [Added in TB 137]

Decode the provided header into a readable format according to RFC 2047.

Parameters

headerName

headerName

(string)

headerValue

headerValue

(string or array of string)

isMailBoxHeader

[isMailBoxHeader]

(boolean, optional)

Headers containing multiple mailbox strings need special handling. For example the header =?UTF-8?Q?H=C3=B6rst=2C_Kenny?= <K.Hoerst@invalid>, new@thunderbird.bug will be wrongly decoded to Hörst, Kenny <K.Hoerst@invalid>, new@thunderbird.bug, corrupting the structure of the first mailbox string. This option overrides the default behavior of treating the headers defined in MailboxHeaders as mailbox headers.

Return type (Promise)

_returns

array of string

encodeMimeHeader(headerName, headerValue, [isMailBoxHeader])

– [Added in TB 137]

Encode the provided header according to RFC 2047.

Parameters

headerName

headerName

(string)

headerValue

headerValue

(string or array of string)

isMailBoxHeader

[isMailBoxHeader]

(boolean, optional)

Headers containing multiple mailbox strings need special handling. This option overrides the default behavior of treating the headers defined in MailboxHeaders as mailbox headers.

Return type (Promise)

_returns

array of string

formatFileSize(sizeInBytes)

– [Added in TB 137]

Returns the provided file size in a human readable format (e.g. 12 bytes or 11,4 GB).

Parameters

sizeInBytes

sizeInBytes

(integer)

The size in bytes.

Return type (Promise)

_returns

string

parseMailboxString(mailboxString, [options])

– [Added in TB 137]

Parse a mailbox string containing one or more email addresses (see RFC 5322, section 3.4).

Parameters

mailboxString

mailboxString

(string)

The string to be parsed (e.g. User <user@example.com>, other-user@example.com)

options

[options]

(boolean or object, optional)

(boolean) Deprecated.

Keep grouped hierarchies. Groups may be specified in a mailbox string as follows: GroupName : user1 <user1@example.com>, user2@example,com ;.

or (object)

expandMailingLists

[expandMailingLists]

(boolean, optional)

– [Added in TB 147]

Expand Thunderbird mailing lists (specified as ListName <ListName>) and include the parsed primary email addresses of all members. When used together with preserveGroups, the mailing list’s name and hierarchy are preserved. If the mailing list does not exist, or the addressBook permission is not granted, the entries are not expanded and returned unchanged.

preserveGroups

[preserveGroups]

(boolean, optional)

– [Added in TB 147]

Keep grouped hierarchies. Groups may be specified in a mailbox string as follows: GroupName : user1 <user1@example.com>, user2@example,com ;.

Return type (Promise)

_returns

array of ParsedMailbox

Types

MailboxHeaders

– [Added in TB 137]

MIME headers, which by default are treated as containing one or more mailbox strings.

string

Supported values:

approved

approved

bcc

bcc

cc

cc

delivered-to

delivered-to

disposition-notification-to

disposition-notification-to

from

from

mail-followup-to

mail-followup-to

mail-reply-to

mail-reply-to

reply-to

reply-to

resent-bcc

resent-bcc

resent-cc

resent-cc

resent-from

resent-from

resent-reply-to

resent-reply-to

resent-sender

resent-sender

resent-to

resent-to

return-receipt-to

return-receipt-to

sender

sender

to

to

ParsedMailbox

– [Added in TB 137]

Representation of a parsed mailbox string (see RFC 5322, section 3.4).

object

email

[email]

(string, optional)

The addr-spec associated with the provided address, if available.

group

[group]

(array of ParsedMailbox, optional)

The members of the group, if available.

name

[name]

(string, optional)

The display-name associated with the provided address or group, if available.