ConnectorTypeIMAP
class connector_types.connector_type_imap.ConnectorTypeIMAP
Access an IMAP mailbox.
Supported commands
capabilitiesQuery server capabilities Returns a list of IMAP4 capabilities as responded by the server.list_foldersList available folders. Returns a list of dictionaries describing the folders on the IMAP server.folder_infoFetch information about a folder Returns a dictionary containing the folder informationsearchSearch for messages in a folder. The folder can be specified in thefolderinput. Search criteria can be specified in thecriteriainput. Returns a list of message IDs.idleWait for the next message (IMAP IDLE / push instead of polling). Blocks until a message matching the searchcriteria(defaultUNSEEN) is present in thefolder. By default (timeout= 0) it waits indefinitely; the connector re-issues IDLE internally to keep the session alive, so the caller never handles IMAP protocol timeouts. Set a positivetimeoutto bound the wait and returntimed_out: true. Requires the server IDLE capability (RFC 6851 / RFC 2177). Returns{'message_ids': [...], 'timed_out': bool, 'folder': str}— fetch the returned ids with thefetchmode.fetchFetch messages. Text payloads will be included in the outputs. Other payloads will be stored as Cloudomation Engine files if thestore_attachmentsinput is set to True The folder can be specified in thefolderinput. The message IDs to fetch can be specified in themessage_setinput. Returns a dictionary describing the fetched messages. Each message includes aninternaldatefield: the server-assigned receive time (ISO-8601, ornullif the server did not supply it). Unlike the sender-setdateheader,internaldateis authoritative and can be used to order messages deterministically.add_flagsAdd flags to messages. The folder can be specified in thefolderinput. The message IDs to fetch can be specified in themessage_setinput. The flags to add can be specified in theflagsinput. Returns a dictionary describing the flags of the messages.get_flagsGet flags of messages. The folder can be specified in thefolderinput. The message IDs to fetch can be specified in themessage_setinput. Returns a dictionary describing the flags of the messages.remove_flagsRemove flags from messages. The folder can be specified in thefolderinput. The message IDs to fetch can be specified in themessage_setinput. The flags to remove can be specified in theflagsinput. Returns a dictionary describing the flags of the messages.set_flagsSet flags of messages. The folder can be specified in thefolderinput. The message IDs to fetch can be specified in themessage_setinput. The flags to set can be specified in theflagsinput. Returns a dictionary describing the flags of the messages.moveMove messages to a folder The source folder can be specified in thefolderinput. The target folder can be specified in thetarget_folderinput. The message IDs to fetch can be specified in themessage_setinput. Requires the MOVE capability of the IMAP server. See RFC 6851.deleteDelete messages. The message IDs to delete can be specified in themessage_setinput. Returns a dictionary describing the flags of the deleted messages.
Input Schema
-
schema_version = '10.0'Type:
string -
authenticationType:
anyOfOptions: -
hostThe remote hostname or IP address.
Type:
string -
portType:
anyOfOptions: -
tlsIf to connect using TLS/SSL.
Type:
anyOfOptions: -
modeType:
anyOfOptions: -
idempotentWhether re-running this connection from the start is safe (no duplicate side effects). Controls recovery after the connection between Cloudomation and the remote system is lost and later re-established (network glitch, workspace restart, ...): repeatable connections are left running to be reattached or re-run, others are cancelled. Leave unset to let the connector decide based on the operation.
Output Schema
Constants
supports_reconnect = FalseExample
List all available folders of a mailbox:
import flow_api
def handler(system: flow_api.System, this: flow_api.Execution, inputs: dict):
folders = this.connect(
connector_type='IMAP',
authentication={
'authentication_method': 'username_password',
'username': '...',
'password': '...',
},
host='...',
port=...,
mode={
'mode_name': 'list_folders',
},
).get('output_value')['result']
this.log(folders=folders)
return this.success('all done')
List all unread (unseen) messages in a folder:
import flow_api
def handler(system: flow_api.System, this: flow_api.Execution, inputs: dict):
message_ids = this.connect(
connector_type='IMAP',
authentication={
'authentication_method': 'username_password',
'username': '...',
'password': '...',
},
host='...',
port=...,
mode={
'mode_name': 'search',
'folder': 'INBOX',
'criteria': [
'UNSEEN',
],
},
).get('output_value')['result']
this.log(message_ids=message_ids)
return this.success('all done')
Fetch a message:
import flow_api
def handler(system: flow_api.System, this: flow_api.Execution, inputs: dict):
messages = this.connect(
connector_type='IMAP',
authentication={
'authentication_method': 'username_password',
'username': '...',
'password': '...',
},
host='...',
port=...,
mode={
'mode_name': 'fetch',
'message_set': [
'1,8:15',
],
},
).get('output_value')['result']
this.log(messages=messages)
return this.success('all done')
Mark a message as unseen:
The flag which is used to track seen/unseen status might differ between IMAP implementations.
import flow_api
def handler(system: flow_api.System, this: flow_api.Execution, inputs: dict):
folders = this.connect(
connector_type='IMAP',
authentication={
'authentication_method': 'username_password',
'username': '...',
'password': '...',
},
host='...',
port=...,
mode={
'mode_name': 'remove_flags',
'message_set': [
'15',
],
'flags': [
'\Seen',
],
},
).get('output_value')['result']
this.log(folders=folders)
return this.success('all done')