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.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.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
-
hostType:
string -
portType:
anyOfOptions: -
use_sslWhether or not to connect using IMAP4-over-SSL.
Type:
booleanDefault:
True -
loginType:
anyOfOptions: -
passwordType:
anyOfOptions: -
modeThe mode to operate in.
Type:
anyOfOptions: -
commandDEPRECATED. Replaced by
mode.mode_name. -
folderDEPRECATED. Replaced by
mode.folder. -
target_folderDEPRECATED. Replaced by
mode.target_folder. -
criteriaDEPRECATED. Replaced by
mode.criteria. -
message_setDEPRECATED . Replaced by
mode.message_set. -
store_attachmentsDEPRECATED. Replaced by
mode.store_attachments. -
flagsDEPRECATED. Replaced by
mode.flags.
Output Schema
-
resultData
Constants
ssl_context_inputs = ['check_hostname', 'client_cert', 'client_key', 'server_ca']Example
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',
host='imap.gmail.com',
port=993,
use_ssl=True,
login='example@gmail.com',
password='***',
command='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',
host='imap.gmail.com',
port=993,
use_ssl=True,
login='example@gmail.com',
password='***',
command='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',
host='imap.gmail.com',
port=993,
use_ssl=True,
login='example@gmail.com',
password='***',
command='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',
host='imap.gmail.com',
port=993,
use_ssl=True,
login='example@gmail.com',
password='***',
command='remove_flags',
message_set=[
'15',
],
flags=[
'\Seen',
],
).get('output_value')['result']
this.log(folders=folders)
return this.success('all done')