The IMAP Plugin

The IMAP Plugin enables interacting with IMAP servers from ACTHEX. It partially implements the client-side of the Internet Message Access Protocol (IMAP) to allow the integration of email messages into ACTHEX programs. It is compatible with the Hexlite solver for HEX programs.


Download

The following link directs to a repository containing the IMAP Plugin together with a full documentation of the plugin:

External Atoms and Action Atoms



#login establishes a connection to an IMAP server.

#login[ConnectionID, Hostname, Port, Username, Password, SSL]
Input:
ConnectionID
term identifying an IMAP server to connect to
Hostname
string containing an IMAP server’s hostname
Port
integer representing an IMAP server’s port
Username
string containing an email account’s user name
Password
string containing an email account’s password
SSL
flag (0 or 1) representing whether to establish an encrypted connection or not

Example:

The execution of the following action causes to login with connection ID connectionID at server example.com:143 with username ”user1@example.com” and password ”password123” without SSL encryption:
#login[connection1, ”example.com”, 143, ”user1@example.com”, ”password123”, 0].


&logged_in evaluates to true iff there already exists a connection with the given ConnectionID.

&logged_in[ConnectionID]
Input:
ConnectionID
term identifying an IMAP server connection

Example:

The evaluation of the following rules results in login_successful being true or false depending if there is a connection with connection ID connection1:
login_successful :- &logged_in[connection1].
−login_successful :- not &logged_in[connection1].


&mailbox returns the mailboxes in the in a specified path with a specified name.

&mailbox[ConnectionID, Path, Name](Mailbox)
Input:
ConnectionID
term identifying an IMAP server connection
Path
string containing a path in which to search for mailboxes
Name
string containing a mailbox name with wildcards
Output:
Mailbox
string containing a matching mailbox name

Example:

The following rule creates a mailbox-atom for each mailbox at the email account identified by connection1 in path "INBOX" that has "Junk" in its name (e.g. "INBOX/Junk-Mail"):
mailbox(M) :- &mailbox[connection1, ”INBOX”, ”Junk*”](M).


&filter returns the message IDs of specified messages.

&filter[ConnectionID, Mailbox, Filter](MessageID)
Input:
ConnectionID
term identifying an IMAP server connection
Mailbox
string containing a mailbox name
Filter
string containing an filter
Output:
MessageID
integer representing a message ID

Example:

The following rule creates a message_id-atom for each message in "INBOX" that is from user2.example.com or has a "Deleted" flag:
message_id(ID) :- &filter[connection1, ”INBOX”, ”or from ′user2.example.com′ deleted”](ID).


&msg_header returns message headers of a specified message.

&msg_header[ConnectionID, Mailbox, MessageID](Type, Value)
Input:
ConnectionID
term identifying an IMAP server connection
Mailbox
string containing a mailbox name
MessageID
integer representing a message ID
Output:
Type
term describing a type of header information
Value
string containing the according header information

Example:

The following rule creates a header-atom for each message header of the message with ID 3 in "INBOX":
header(T, V) :- &msg_header[connection1, ”INBOX”, 3](T, V).


&msg_body returns the body of a specified message.

&msg_body[ConnectionID, Mailbox, MessageID](Body)
Input:
ConnectionID
term identifying an IMAP server connection
Mailbox
string containing a mailbox name
MessageID
integer representing a message ID
Output:
Body
containing the specified message’s body

Example:

The following rule creates a body-atom for the message with ID 3 in "INBOX":
body(B) :- &msg_body[connection1, ”INBOX”, 3](B).


#set_flag sets a flag for a message.

#set_flag[ConnectionID, Mailbox, MessageID, Flag]
Input:
ConnectionID
term identifying an IMAP server connection
Mailbox
string containing a mailbox name
MessageID
integer representing a message ID
Flag
string representing a flag

Example:

The execution of the following action causes the message with ID 3 in "INBOX" to be marked with a "Deleted"-flag:
#set_flag[connection1, ”INBOX”, 3, ”Deleted”].


#copy_msg copies a message to another mailbox.

#copy_msg[ConnectionID, Mailbox, MessageID, NewMailbox]
Input:
ConnectionID
term identifying an IMAP server connection
Mailbox
string containing a mailbox name
MessageID
integer representing a message ID
NewMailbox
string containing a mailbox name

Example:

The execution of the following action causes the message with ID 3 in "INBOX" to be copied to ”INBOX/Junk E−Mail”:
#copy_msg[connection1, ”INBOX”, 3, ”INBOX/Junk E−Mail”].


#create_msg creates a specified message.

#create_msg[ConnectionID, Mailbox, Sender, Subject, Recipient, CC, BCC, Text]
Input:
ConnectionID
term identifying an IMAP server connection
Mailbox
string containing a mailbox name
Sender
string containing a message’s sender
Subject
string containing a message’s subject
Recipient
function with name recipient and an arbitrary number of strings as terms
CC
function with name cc and an arbitrary number of strings as terms
BCC
function with name bcc and an arbitrary number of strings as terms
Text
string containing a message’s text

Example:

The execution of the following action causes the creation of the draft of a new message from ”user1@example.com” with subject ”subject1” to ”user2@example.com” and ”user3@example.com” with text "text123" in "INBOX":
#create_msg[connection1, INBOX, ”user1@example.com”, ”subject1”,
”recipient(”user2@example.com”, ”user3@example.com”), cc(), bcc(), ”text123”].


#move_msg movies a message to another mailbox.

#move_msg[ConnectionID, Mailbox, MessageID, NewMailbox]
Input:
ConnectionID
term identifying an IMAP server connection
Mailbox
string containing a mailbox name
MessageID
integer representing a message ID
NewMailbox
string containing a mailbox name

Example:

The execution of the following action causes the message with ID 3 to be moved from "INBOX" to "INBOX/Junk E-Mail":
#move_msg[connection1, ”INBOX”, 3, ”INBOX/Junk E−Mail”].


#expunge_msgs expunges all messages in the specified mailbox with a \Deleted flag.

#expunge_msgs[ConnectionID, Mailbox]
Input:
ConnectionID
term identifying an IMAP server connection
Mailbox
string containing a mailbox name

Example:

The execution of the following action causes all messages in "INBOX" that have a "Deleted" flag to be expunged:
#expunge_msgs[connection1, ”INBOX”].


#create_mailbox creates a new mailbox.

#create_mailbox[ConnectionID, Mailbox]
Input:
ConnectionID
term identifying an IMAP server connection
Mailbox
string containing a new mailbox name

Example:

The execution of the following action causes the creation of a new mailbox with name "INBOX/Mailbox2".
#create_mailbox[connection1, ”INBOX/Mailbox2”].


#delete_mailbox deletes a mailbox.

#delete_mailbox[ConnectionID, Mailbox]
Input:
ConnectionID
term identifying an IMAP server connection
Mailbox
string containing a mailbox name

Example:

The execution of the following action causes mailbox "INBOX" to be deleted:
#delete_mailbox[connection1, ”INBOX”].


#rename_mailbox renames a mailbox.

#rename_mailbox[ConnectionID, Mailbox, NewMailbox]
Input:
ConnectionID
term identifying an IMAP server connection
Mailbox
string containing a mailbox name
NewMailbox
string containing a new mailbox name

Example:

The execution of the following action causes mailbox "Mailbox1" to be renamed to "Mailbox2":
#rename_mailbox[connection1, ”Mailbox1”, ”Mailbox2”].


#reply creates the draft of a reply message for a specified message.

#reply[ConnectionID, Mailbox, MessageID, Text]
Input:
ConnectionID
term identifying an IMAP server connection
Mailbox
string containing a mailbox name
MessageID
integer representing a message ID
Text
string containing a text to be replied

Example:

The execution of the following action causes the creation of a draft in "INBOX" with text "text123". The new message has the recipient of the message with ID 3 as its sender, the sender of the message of ID 3 as its recipients and the subject of the message with ID 3 with a prefixed "Re: ":
#reply[connection1, ”INBOX”, 3, ”text123”].


 

General
dlvhex source code @ github.com
Description-Of-A-Project

Popular Plugins
Action Plugin
DecisionDiagrams Plugin
Description Logics Plugin
Description Logics Lite Plugin
MELD: Belief Merging Plugin
Nested HEX Plugin
MCSIE Plugin
String Plugin
dlvhex-semweb Project
IMAP Acthex Plugin

Documentation
User Guide
README
doxygen
Writing Plugins in C++
Writing Plugins in Python