messengerUtilities API

Functions

convertToPlainText(body, [options])

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

Parameters

body

(string)

The to-be-converted body.

[options]

(object, optional)

[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)

string

decodeMimeHeader(headerName, headerValue, [isMailBoxHeader])

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

Parameters

headerName

(string)

headerValue

(string or array of string)

[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)

array of string

encodeMimeHeader(headerName, headerValue, [isMailBoxHeader])

Encode the provided header according to RFC 2047.

Parameters

headerName

(string)

headerValue

(string or array of string)

[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)

array of string

formatFileSize(sizeInBytes)

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

Parameters

sizeInBytes

(integer)

The size in bytes.

Return type (Promise)

string

parseMailboxString(mailboxString, [preserveGroups])

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

Parameters

mailboxString

(string)

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

[preserveGroups]

(boolean, optional)

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

Return type (Promise)

array of ParsedMailbox

Types

MailboxHeaders

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

string

Supported values:

bcc

cc

from

reply-to

resent-bcc

resent-cc

resent-from

resent-reply-to

resent-sender

resent-to

sender

to

approved

disposition-notification-to

delivered-to

return-receipt-to

mail-reply-to

mail-followup-to

ParsedMailbox

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

object

[email]

(string, optional)

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

[group]

(array of ParsedMailbox, optional)

The members of the group, if available.

[name]

(string, optional)

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