email/Messages

Collection of emails bound to email accounts and directories (for incoming emails). The collection is created and used by the 'email' microservice. Has type history or transactionlog, is partitioned and addressed using dates.

Entities for received emails are created automatically during IMAP directory synchronization with the IMAP server. Sent email entities are created via the API or by other system services.

Emails have states affecting the servicing process. Thus, to send an email the 'messageState' must be set to 'sending', and after sending it is automatically set to 'sent'. Additionally, for sending, the 'messageDirection' field must contain the value 'out'.

WARNING! All attachments, HTML content, and the native unparsed email content are saved as attachments and stored in the file system. This imposes restrictions on the file system, whose inode count may be quickly exhausted if it is initially limited at the attachment storage location.

Storage type: history or transactionlog.

Table 1. Class fields
Field Description

id

Identifier.

account_id

Parent email account identifier.

folder_id

Directory identifier.

dateTime

Email date-time. Also used when determining the DB storage partition. For sent emails, populated by the initiating service before sending, used when forming the queue. For received emails, populated automatically, predominantly the original time the email arrived on the server (Date or Delivery-Date headers).

messageDirection

Email direction:

  • in - incoming email.

  • out - outgoing/sent email. Serves as a filter for the sending service.

messageType

Email type:

  • text - text

  • html - html document

  • alternative - alternatives present (most often both text and html)

  • undefined - content of other types

messageState

Email state:

  • sending - email ready for sending. Serves as a filter for the sending service.

  • sent - email sent.

  • error - sending error.

  • received - received email.

  • raw - email received but not parsed due to a failure.

  • undefined - unknown state.

statusText

Populated with error content if the received email has the error state, or an error occurred during sending.

uidValidity

Original IMAP set identifier (in received emails). Used to discover the next unreceived email.

uid

Original incremental email identifier within its IMAP uidValidity (in received emails). Used to discover the next unreceived email.

from

Email sender address (in received emails)

to

List of email recipient addresses. Populated automatically for received emails. Used when sending emails.

copy

List of other recipient email addresses via copy (for sent emails).

blindCopy

List of hidden recipient email addresses (for sent emails).

replyTo

Email address for automatic reply. For sent emails, if the value is empty, the value from the account options (the 'options.replyTo' field) is taken, otherwise the destination address value ('to') is substituted.

inReplyTo

Email address to substitute into the In-Reply-To header of sent emails.

nativeId

Original email identifier (for received emails).

nativeDateTime

Original email time (for received emails). Extracted from the Date or Delivery-Date headers.

recvDateTime

Date-time of actual reception of the incoming email from the mail server and entity creation. Populated automatically for received emails.

references

subject

Email subject.

body

Message body if it is neither text nor html (for received emails).

bodyText

Message text if the content contains a text data block (text/plain directly or in multipart/alternative). For sent emails, populated by the initiator before sending. For received emails, populated automatically after successful email parsing.

html

Email HTML content (attachment) if the content contains an html data block (text/html directly or in multipart/alternative). For sent emails, populated by the initiator before sending. For received emails, populated automatically after successful email parsing. The file is placed on disk; meta-information is saved in the entity.

size

Message size (for received emails)

attachments

List of attachments, including inline ones (multipart/mixed). For sent emails, populated by the initiator before sending. For received emails, populated automatically after successful email parsing. Attachments are placed on disk; meta-information is saved in the entity.

attachmentInfo

Object - list of inline resources (resources with links from the email body). When sending an email, a specific set of parameters can be set using the object. In particular, the 'Content-Type' header value can be set for a specific attachment. For attachments requiring specific parameters, the object must contain a key - the file name in the 'attachments' collection, and a value - an object with a set of supported properties: 'content_type'.

For example:

{
  "file.ics": {"content_type": "text/calendar; charset=utf-8; method=REQUEST; name=file.ics"}
}

inlineInfo

Object - list of inline resources (resources with links from the email body). Placed in one 'multipart/related' part with the email HTML body. To send inline resources, specify an object where keys are Content-Ids and values are file names in the attachments collection.

For example:

{
  "15623784-1562-3784-5906-156237845906": "myfile.png"
}

rawMessage

Original unparsed incoming email (for received emails). The file is placed on disk; meta-information is saved in the entity.