imap

imap to receive your emails

Current Release
0.4.0
Developer
Lucky-ESA
License
MIT
 ⚠ This adapter can crash the system very quickly with the Blockly (own query).
 ⚠ So please read this description carefully.

Back to the README

Summary

Instance Settings

Instance settings TAB - Create IMAP`s

Summary

 ⚠ The instance must be activated!!!!
  • Activ: Enable IMAP connection
  • Host: Host - e.g. imap.gmail.com
  • Inbox: Default INBOX - Box to be monitored - Possible selection see imap.0.xxx.remote.change_folder example: INBOX.subfolder (point as separator)
  • Port: Port - Default 993
  • Username: Username - Instance must be activated!!!
  • Password: Password - Instance must be activated!!!

imap_create_1.png

  • max.: Create maximum as States - email_01...email_02... (1-99)
  • max. HTML: Maximum number of emails as HTML. Should be greater than max States (1-99)
  • TLS: Use TLS-Connection - Default true
  • Flags: Flags for the query - Possible flags:
ALL - All messages.
ANSWERED - Messages with the Answered flag set.
DELETED - Messages with the Deleted flag set.
DRAFT - Messages with the Draft flag set.
FLAGGED - Messages with the Flagged flag set.
NEW - Messages that have the Recent flag set but not the Seen flag.
SEEN - Messages that have the Seen flag set.
RECENT - Messages that have the Recent flag set.
OLD - Messages that do not have the Recent flag set. This is functionally equivalent to "!RECENT" (as opposed to "!NEW").
UNANSWERED - Messages that do not have the Answered flag set.
UNDELETED - Messages that do not have the Deleted flag set.
UNDRAFT - Messages that do not have the Draft flag set.
UNFLAGGED - Messages that do not have the Flagged flag set.
UNSEEN - Messages that do not have the Seen flag set.
  • Choose icon: Folder icon (upload under TAB CREATE ICON)

imap_create_icon.png

  • tls Option: Default {"rejectUnauthorized": false}
  • auto tls: Set to always to always attempt connection upgrades via STARTTLS, required only if upgrading is required, or never to never attempt upgrading. Default: never For more information

imap_create_2.png

  • Att.: In order to fill the HTML field, attachments must also be loaded. Very high RAM consumption!!! Default false
  • Mail option: Mailparser-Option (Create under TAB MAILPARSER OPTIONEN)
  • Token: Token first create

imap_create_3.png

  • max. MEMRSS-Limit: From when the actions listed below should be triggered. Default 400 MB
  • Restart: When the MEMRSS limit is reached, the adapter restarts. It is checked every 24 hours.

imap_create_restart.png

  • Object-ID: When the MEMRSS limit is reached, the selected state is set to true. This must be reset manually. It is checked every 24 hours.

imap_create_datapoint.png

  • Send: A message is sent when the MEMRSS limit is reached. A message will then be sent whenever MEMRSS is updated.
    • Instance: e. g. telegram.0,telegram.1,pushover.0
    • Instance User: e. g. Peter,Olaf,Thomas

imap_create_send.png

Instance settings TAB - Create ICONS

Summary

  • Icon Name: Name for the icon. Please do not use duplicate names. An error message is output when the adapter starts.
  • Upload: Upload icon.

imap_create_icon.png

Instance settings TAB - oauth2

Summary

  • Name Name
  • Client ID Client-ID
  • Token Token
  • Tenant ID Mandaten-ID

imap_create_oauth2.png
token_id.png
client_id.png
mandant_id.png

Instance settings TAB - MAILPARSER OPTIONS

Summary

  • Name: Name for the Mailparser. Please do not use duplicate names. An error message is output when the adapter starts. There is a detailed description here.
  • skip Html To Text: Don’t generate plaintext from HTML.
  • max Html Length To Parse: The maximum amount of HTML to parse in bytes. If this is exceeded, only header data is generated.
  • skip Image Links: Skip converting CID attachments to data URL images. Images are not converted as base64 which saves huge RAM usage.
  • skip Text To Html: Don’t generate HTML from plaintext message.
  • skip Text Links: Do not linkify links in plaintext content.

imap_create_mailparser.png

States

State imap.0

Summary

ObjectDescription
imap.0.json_imapName of the IMAP connection of the last activity. Trigger for incoming emails or updates.
imap.0.json_tableLast update of an IMAP connection as a JSON table for VIS.
imap.0.online_counterNumber of active IMAP connections.
imap.0.online_historyConnection activity history as JSON - Example.

imap_total_overview.png

State imap.0.username

Summary

ObjectDescription
imap.0.xxx.active_inboxActive Inbox
imap.0.xxx.hostHostname
imap.0.xxx.htmlHTML Code for VIS
imap.0.xxx.jsonJSON Table for VIS - Example
imap.0.xxx.last_activityLast activity
imap.0.xxx.last_activity_jsonActivity as array JSON - Example
imap.0.xxx.last_activity_timestampLast activity timestamp
imap.0.xxx.onlineIMAP status Verbindung
imap.0.xxx.qualityQuality of all States as JSON. Is updated every 24 hours - Example
imap.0.xxx.statusInformation about the IMAP connection as JSON - Example
imap.0.xxx.totalTotal eMails
imap.0.xxx.total_unreadTotal unread eMails

imap_overview_1.png

State imap.0.username.email.email_xx

Summary

ObjectDescription
imap.0.xxx.email.email_01.attachNumber of attachments and images in the body
imap.0.xxx.email.email_01.attach_jsonInfos der Anhänge als JSON - Beispiel
imap.0.xxx.email_01.contentContent of the email
imap.0.xxx.email.email_01.flagEmail flags
imap.0.xxx.email.email_01.fromAll sender as Array
imap.0.xxx.email.email_01.receiveReceived date
imap.0.xxx.email.email_01.seqSequence number
imap.0.xxx.email.email_01.sizeSize of the email in bytes
imap.0.xxx.email.email_01.subjectSubject
imap.0.xxx.email.email_01.texthtmlContent as HTML
imap.0.xxx.email.email_01.toRecipient as Array
imap.0.xxx.email.email_01.uidUnique UID

imap_overview_email_single.png imap_overview_email.png

State imap.0.username.infos

Summary

ObjectDescription
imap.0.xxx.infos.all_capabilityAll capability from IMAP connection
imap.0.xxx.infos.auth_cram-md5Authentication method auth_cram-md5
imap.0.xxx.infos.auth_xoauthAuthentication method xoauth
imap.0.xxx.infos.auth_xoauth2Authentication method xoauth2
imap.0.xxx.infos.condstoreMODSEQ request possible lookup
imap.0.xxx.infos.esearchSearch multiple mailboxes with one command
imap.0.xxx.infos.idlookup
imap.0.xxx.infos.idlelookup
imap.0.xxx.infos.literal*lookup
imap.0.xxx.infos.logindisabledlookup
imap.0.xxx.infos.moveEmails can be moved. lookup
imap.0.xxx.infos.namespacelookup
imap.0.xxx.infos.quotalookup
imap.0.xxx.infos.sasl-irlookup
imap.0.xxx.infos.sorte-mails are retrieved sorted lookup
imap.0.xxx.infos.sort_displayHeader info is sorted. lookup
imap.0.xxx.infos.starttlsStarttls is supported. Can then be set in the instance settings. lookup
imap.0.xxx.infos.thread_orderedsubjectlookup
imap.0.xxx.infos.thread_referenceslookup
imap.0.xxx.infos.unselectlookup
imap.0.xxx.infos.x-gm-ext-1lookup

imap_overview_capability.png imap_overview_capability_1.png

State imap.0.username.remote

Summary

ObjectDescription
imap.0.xxx.remote.apply_htmlApply change in imap.0.xxx.remote.html.
imap.0.xxx.remote.change_folderInstance settings: Change post folder to be monitored and displayed. Will only be reset after a reboot.
imap.0.xxx.remote.criteriaInstance settings: Change search. Will only be reset after a reboot.
imap.0.xxx.remote.mailbox_folder_change_nameChange name of mailbox folder Example ["INBOX.imap", "INBOX.newimap"] see
imap.0.xxx.remote.mailbox_folder_createCreate mailbox folder
imap.0.xxx.remote.mailbox_folder_deleteDelete mailbox folder
imap.0.xxx.remote.reload_emailsReload emails.
imap.0.xxx.remote.search_startApply changes from change_folder, criteria and show_mails
imap.0.xxx.remote.show_mailsInstance settings: Number of emails (max. HTML) to be loaded. Will only be reset after a reboot. Should of course be greater than the value max.
imap.0.xxx.remote.vis_commandCommand from the VIS to move mails from the selection boxes. Only used by VIS.

imap_overview_remote.png

Folder name

Old folder names can be viewed in the imap.0.xxx.remote.change_folder object

State imap.0.username.remote.copy

Summary

ObjectDescription
imap.0.xxx.remote.copy.apply_copyApply change of copy.folder and copy.uid.
imap.0.xxx.remote.copy.folderSelect folder in which the selected mail should be copied.
imap.0.xxx.remote.copy.uidEnter the UID of the email to be copied here. You can find the UID in imap.0.xxx.json or in the email folders

imap_overview_remote_copy.png

State imap.0.username.remote.flag

Summary

ObjectDescription
imap.0.xxx.remote.flag.apply_flagApply change of set, type and uid.
imap.0.xxx.remote.flag.setSelect setFlag, addFlag and delFlag.
imap.0.xxx.remote.flag.typeSelect flag to add, set or delete.
imap.0.xxx.remote.flag.uidThe UID to which the flag change should be made. You can find the UID in imap.0.xxx.json or in the email folders.

imap_overview_remote_flag.png

State imap.0.username.remote.html

Summary

ObjectDescription
imap.0.xxx.remote.html.body_backgroundBackground Body - Default #000000
imap.0.xxx.remote.html.choose_contentDisplay attribute from email.
Possible fields are html, text, textAsHtml and html convert.
imap.0.xxx.remote.html.header_borderHeader border - Default 2 px
imap.0.xxx.remote.html.header_fontHeader font - Default Helvetica
imap.0.xxx.remote.html.header_font_sizeHeader font size - Default 15 px
imap.0.xxx.remote.html.header_linear_color_1Gradient background header value 1 - Default #424242
imap.0.xxx.remote.html.header_linear_color_2Gradient background header value 2 - Default #424242
imap.0.xxx.remote.html.header_tag_border_colorHeader border color - Default #424242 - Everything possible
imap.0.xxx.remote.html.header_text_colorHeader text color - Default #BDBDBD
imap.0.xxx.remote.html.header_widthHeader width - Default auto - Possible px or %
imap.0.xxx.remote.html.headline_align_column_1Header align column 1 - Default center
Possible center, left, right and auto

imap_overview_remote_html_1.png

ObjectDescription
imap.0.xxx.remote.html.headline_align_column_2Text alignment header column 2 - Default center
Possible center, left, right and auto
imap.0.xxx.remote.html.headline_align_column_3Text alignment header column 3 - Default center
Possible center, left, right and auto
imap.0.xxx.remote.html.headline_align_column_4Text alignment header column 4 - Default center
Possible center, left, right and auto
imap.0.xxx.remote.html.headline_align_column_5Text alignment header column 5 - Default center
Possible center, left, right and auto
imap.0.xxx.remote.html.headline_align_column_6Text alignment header column 6 - Default center
Possible center, left, right and auto
imap.0.xxx.remote.html.headline_align_column_7Text alignment header column 7 - Default center
Possible center, left, right and auto
imap.0.xxx.remote.html.headline_align_column_8Text alignment header column 8 - Default center
Possible center, left, right and auto
imap.0.xxx.remote.html.headline_align_column_9Text alignment header column 9 - Default center
Possible center, left, right and auto
imap.0.xxx.remote.html.headline_align_column_10Text alignment header column 10 - Default center
Possible center, left, right and auto
imap.0.xxx.remote.html.headline_colorBorder color Body - Default #BD5A3C
imap.0.xxx.remote.html.headline_column_width_1column width column 1 - Default auto - Possible px or %
imap.0.xxx.remote.html.headline_column_width_10column width column 10 - Default auto - Possible px or %

imap_overview_remote_html_2.png

ObjektDescription
imap.0.xxx.remote.html.headline_column_width_2column width column 2 - Default auto - Possible px or %
imap.0.xxx.remote.html.headline_column_width_3column width column 3 - Default auto - Possible px or %
imap.0.xxx.remote.html.headline_column_width_4column width column 4 - Default auto - Possible px or %
imap.0.xxx.remote.html.headline_column_width_5column width column 5 - Default auto - Possible px or %
imap.0.xxx.remote.html.headline_column_width_6column width column 6 - Default auto - Possible px or %
imap.0.xxx.remote.html.headline_column_width_7column width column 7 - Default auto - Possible px or %
imap.0.xxx.remote.html.headline_column_width_8column width column 8 - Default auto - Possible px or %
imap.0.xxx.remote.html.headline_column_width_9column width column 9 - Default auto - Possible px or %
imap.0.xxx.remote.html.headline_font_sizeFont size in the cell - Default 16 px
imap.0.xxx.remote.html.headline_heightCell height - Default 35 px
imap.0.xxx.remote.html.headline_styleStyle Cell - Default normal - Possible normal or bold

imap_overview_remote_html_3.png

ObjektDescription
imap.0.xxx.remote.html.headline_underlinedCell border - Default 3 px
imap.0.xxx.remote.html.headline_underlined_colorCell border color - Default #ffffff
imap.0.xxx.remote.html.jarvisCode customization for View in Jarvis
imap.0.xxx.remote.html.mails_even_colorLine background color for even IDs - Default #333333
imap.0.xxx.remote.html.mails_nextday_color_evenLine background color for even IDs yesterday - Default #F7FFE0
imap.0.xxx.remote.html.mails_nextday_color_oddLine background color for odd IDs yesterday - Default #F7FFE0
imap.0.xxx.remote.html.mails_odd_colorLine background color for odd IDs - Default #FFE32E
imap.0.xxx.remote.html.mails_today_colorLine background color for even IDs today - Default #ffffff
imap.0.xxx.remote.html.mails_today_color_oddLine background color for odd IDs today - Default #ffffff
imap.0.xxx.remote.html.p_tag_text_alignText align Header and Footer - Default center
Possible center, left, right and auto
imap.0.xxx.remote.html.short_contentCharacter limitation in the Content - Default 35
imap.0.xxx.remote.html.short_subjectCharacter limitation in the Subject - Default 35
imap.0.xxx.remote.html.table_tag_border_colorTable border color - Default #424242

imap_overview_remote_html_4.png

ObjektDescription
imap.0.xxx.remote.html.table_tag_cellTable border spacing - Default 6 px
imap.0.xxx.remote.html.table_tag_text_alignTable margin - Default auto - Possible px or %
imap.0.xxx.remote.html.table_tag_widthTable width - Default auto - Possible px or %
imap.0.xxx.remote.html.td_tag_2_columsLine border of line 1 and 2 - Default auto - Possible px or %
imap.0.xxx.remote.html.td_tag_border_bottomLine under border - Default 1 px
imap.0.xxx.remote.html.td_tag_border_colorLine under border color - Default #424242
imap.0.xxx.remote.html.td_tag_border_rightCell border right - Default 1 px
imap.0.xxx.remote.html.td_tag_cellCell spacing in the rows - Default 6 px
imap.0.xxx.remote.html.text_contentHeader text column 5 - Default Content
imap.0.xxx.remote.html.text_dateHeader text column 4 - Default Date
imap.0.xxx.remote.html.text_flagHeader text column 7 - Default Flags
imap.0.xxx.remote.html.text_fromHeader text column 2 - Default From

imap_overview_remote_html_5.png

ObjektDescription
imap.0.xxx.remote.html.text_idHeader text column 1 - Default ID
imap.0.xxx.remote.html.text_move_or_copyHeader text column 9 - Default copy/paste
imap.0.xxx.remote.html.text_select_addflagText in flag selection box - Default addFlags -
imap.0.xxx.remote.html.text_select_copyText in Kopie selection box - Default copy
imap.0.xxx.remote.html.text_select_delflagText in Flag selection box - Default delFlags -
imap.0.xxx.remote.html.text_select_moveText in Kopie selection box - Default move
imap.0.xxx.remote.html.text_select_setflagText in Flag selection box - Default setFlags -
imap.0.xxx.remote.html.text_seqHeader text column 6 - Default SEQ
imap.0.xxx.remote.html.text_setflagHeader text column 10 - Default Flag action
imap.0.xxx.remote.html.text_subjectHeader text column 3 - Default Subject
imap.0.xxx.remote.html.text_uidHeader text column 8 - Default UID
imap.0.xxx.remote.html.top_fontFont Header und Footer - Default Helvetica

imap_overview_remote_html_6.png

ObjektDescription
imap.0.xxx.remote.html.top_font_sizeFont size Header und Footer - Default 20 px
imap.0.xxx.remote.html.top_font_weightSchriftstärke Header und Footer - Default normal - Possible normal or bold
imap.0.xxx.remote.html.top_textHeader text Default the Username
imap.0.xxx.remote.html.top_text_colorHeader text color - Default #ffffff

imap_overview_remote_html_7.png

State imap.0.username.remote.move

Summary

ObjektDescription
imap.0.xxx.remote.move.apply_moveApply change of folder and uid.
imap.0.xxx.remote.move.folderSelect folder in which the selected mail should be moved.
imap.0.xxx.remote.move.uidEnter the UID of the email to be moved here. You can find the UID in imap.0.xxx.json or in the email folders.

imap_overview_remote_move.png

Blocklys

Blockly - Change IMAP query

Summary

  • With this you can set these States.
  • See the instance setting for possible flags.
  • Select IMAP connection or apply to all.
  • Max. 100 emails allowed.

blockly_imap_1.png blockly_imap_2.png

Blockly - IMAP own query

Summary

  • DANGER! Here comes all the data such. E.g. attachments. This query can push the RAM or CPU to the limit. If an incorrect criterion is created, this can lead to an iobroker crash!!!
  • The data is then delivered as JSON.
  • With log outputs, the log file becomes very large. Therefore delete the log outputs again later.
  • A variable called result must be created.
  • Max. 100 emails allowed.
  • Beispiele

blockly_imap_request.png

Blockly - IMAP query with instance settings

Summary

  • Load all data from the IMAP connection and process it yourself. The instance setting is used as the search criterion.
  • DANGER! Higher RAM consumption
  • The data is then delivered as JSON.
  • With log outputs, the log file becomes very large. Therefore delete the log outputs again later.
  • A variable called result must be created.
  • Example

blockly_imap_current.png

Blockly - Set IMAP flags

Summary

  • Set a flag setFlag=set, addFlag=add or delFlag=delete for an email.
  • Select mailbox.
  • Select setFlag=set, addFlag=add or delFlag=delete.
  • select flag.
  • Possible flags in imap.0.xxx.status

blockly_imap_flag.png

Array JSON

Array JSON imap.0.xxx.email.email_xx.attach_json

Summary

[
    {
        "partID": "2",
        "id": "<image001.png@01D9C718.240FAD50>",
        "uid": 86,
        "size": "159762",
        "filename": "image001.png",
        "type": "inline",
        "encoding": "base64"
    },
    {
        "partID": "3",
        "id": "<image002.png@01D9C718.36F8AE30>",
        "uid": 86,
        "size": "1296247",
        "filename": "image002.png",
        "type": "inline",
        "encoding": "base64"
    }
]

Array JSON imap.0.xxx.json

Summary

[
    {
        "id": 1,
        "date": "15.08.2023 15:39:17",
        "from": ["test@luckyskills.de"],
        "from_name": ["Tester"],
        "attach": 0,
        "attach_info": [],
        "to": ["github@luckyskills.de"],
        "to_name": ["Lucky-ESA"],
        "subject": "Test",
        "text": "Am 2023-08-10 12:17, schrieb test@luckyskills.de:\n>>> TEST\n",
        "html": false,
        "textAsHtml": "Am 2023-08-10 12:17, schrieb <a href=\"mailto:test@luckyskills.de\">test@luckyskills.de</a>:<br/>&gt;&gt;&gt; TEST</p>",
        "seqno": 74,
        "uid": 93,
        "size": 1077,
        "flag": "unseen"
    }
]

JSON imap.0.xxx.last_activity_json

Summary

{
    "modseq": "196",
    "flags": ["\\Seen"]
}

JSON imap.0.xxx.quality

Summary

{
    "message": "No Message"
}

Possibilities

0: "0x00 - good",
1: "0x01 - general problem",
2: "0x02 - no connection problem",
16: "0x10 - substitute value from controller",
17: "0x11 - general problem by instance",
18: "0x12 - instance not connected",
32: "0x20 - substitute initial value",
64: "0x40 - substitute value from device or instance",
65: "0x41 - general problem by device",
66: "0x42 - device not connected",
68: "0x44 - device reports error",
128: "0x80 - substitute value from sensor",
129: "0x81 - general problem by sensor",
130: "0x82 - sensor not connected",
132: "0x84 - sensor reports error",

JSON imap.0.xxx.status

Summary

{
    "name": "INBOX",
    "flags": ["\\Answered", "\\Flagged", "\\Deleted", "\\Seen", "\\Draft"],
    "readOnly": false,
    "uidvalidity": 1667682367,
    "uidnext": 94,
    "permFlags": ["\\Answered", "\\Flagged", "\\Deleted", "\\Seen", "\\Draft"],
    "keywords": [],
    "newKeywords": true,
    "persistentUIDs": true,
    "nomodseq": false,
    "seq": 0,
    "time": 0,
    "reason": "",
    "user": "github_luckyskills_de",
    "messages": {
        "total": 74,
        "new": 0
    },
    "highestmodseq": "200"
}

Array JSON imap.0.online_history

Summary

[
    {
        "client": "github_luckyskills_de",
        "time": 1692298599784,
        "status": "Online"
    },
    {
        "client": "github_luckyskills_de",
        "time": 1692298232899,
        "status": "Online"
    }
]

Changelog

WORK IN PROGRESS

  • (Lucky-ESA) Admin 7.6.20 required

0.4.0 (2026-05-30)

  • (copilot) Adapter requires node.js >= 22 now
  • (Lucky-ESA) Description revised
  • (Lucky-ESA) Admin 7.8.23 required
  • (Lucky-ESA) JS-Controller 7.0.7 required
  • (Lucky-ESA) Added meta object for attachments

0.3.0 (2024-12-07)

  • (Lucky-ESA) Mailbox folder delete added
  • (Lucky-ESA) Mailbox folder create added
  • (Lucky-ESA) Change Mailbox Folder name added
  • (Lucky-ESA) IMAP package changed
  • (Lucky-ESA) Migration to ESLint9

0.2.2 (2024-11-07)

  • (Lucky-ESA) New design for settings page added
  • (Lucky-ESA) Crash if uid is empty for new emails

0.2.1 (2024-09-16)

  • (Lucky-ESA) Update dependencies
  • (Lucky-ESA) Changed Log info to debug
  • (Lucky-ESA) Fixed blockly setFlag crash

0.2.0 (2024-06-15)

  • (Lucky-ESA) Updated Blockly definitions
  • (Lucky-ESA) JS-Controller >= 5.0.19 required
  • (Lucky-ESA) Admin >=6.13.16 required

License

MIT License

Copyright (c) 2023-2026 Lucky-ESA github@luckyskills.de

Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.