The imapautofiler.actions
Module¶
-
class
imapautofiler.actions.
Action
(action_data, cfg)¶ Bases:
object
Base class
-
NAME
= None¶
-
invoke
(conn, mailbox_name, message_id, message)¶ Run the action on the message.
Parameters: - conn (imapautofiler.client.Client) – connection to mail server
- mailbox_name (str) – name of the mailbox holding the message
- message_id (str) – ID of the message to process
- message (email.message.Message) – the message object to process
-
report
(conn, mailbox_name, message_id, message)¶ Log a message explaining what action will be taken.
-
-
class
imapautofiler.actions.
Delete
(action_data, cfg)¶ Bases:
imapautofiler.actions.Action
Delete the message immediately.
The action is indicated with the name
delete
.-
NAME
= 'delete'¶
-
invoke
(conn, mailbox_name, message_id, message)¶ Run the action on the message.
Parameters: - conn (imapautofiler.client.Client) – connection to mail server
- mailbox_name (str) – name of the mailbox holding the message
- message_id (str) – ID of the message to process
- message (email.message.Message) – the message object to process
-
report
(conn, mailbox_name, message_id, message)¶ Log a message explaining what action will be taken.
-
-
class
imapautofiler.actions.
Flag
(action_data, cfg)¶ Bases:
imapautofiler.actions.Action
Flag the message.
The action is indicated with the name
flag
.-
NAME
= 'flag'¶
-
invoke
(conn, mailbox_name, message_id, message)¶ Run the action on the message.
Parameters: - conn (imapautofiler.client.Client) – connection to mail server
- mailbox_name (str) – name of the mailbox holding the message
- message_id (str) – ID of the message to process
- message (email.message.Message) – the message object to process
-
report
(conn, mailbox_name, message_id, message)¶ Log a message explaining what action will be taken.
-
-
class
imapautofiler.actions.
MarkRead
(action_data, cfg)¶ Bases:
imapautofiler.actions.Action
Mark the message as read
The action is indicated with the name
mark_read
.-
NAME
= 'mark_read'¶
-
invoke
(conn, mailbox_name, message_id, message)¶ Run the action on the message.
Parameters: - conn (imapautofiler.client.Client) – connection to mail server
- mailbox_name (str) – name of the mailbox holding the message
- message_id (str) – ID of the message to process
- message (email.message.Message) – the message object to process
-
report
(conn, mailbox_name, message_id, message)¶ Log a message explaining what action will be taken.
-
-
class
imapautofiler.actions.
MarkUnread
(action_data, cfg)¶ Bases:
imapautofiler.actions.Action
Mark the message as unread
The action is indicated with the name
mark_unread
.-
NAME
= 'mark_unread'¶
-
invoke
(conn, mailbox_name, message_id, message)¶ Run the action on the message.
Parameters: - conn (imapautofiler.client.Client) – connection to mail server
- mailbox_name (str) – name of the mailbox holding the message
- message_id (str) – ID of the message to process
- message (email.message.Message) – the message object to process
-
report
(conn, mailbox_name, message_id, message)¶ Log a message explaining what action will be taken.
-
-
class
imapautofiler.actions.
Move
(action_data, cfg)¶ Bases:
imapautofiler.actions.Action
Move the message to a different folder.
The action is indicated with the name
move
.The action data must contain a
dest-mailbox
entry with the name of the destination mailbox.The
dest-mailbox
value can contain jinja2 template directives using the headers of the message. For example:dest-mailbox: "archive.{{ date.year }}"
will extract the year value from the date header of the message and insert it into the destination mailbox path.
Header names are always all lower case and
-
is replaced by_
.-
NAME
= 'move'¶
-
invoke
(conn, src_mailbox, message_id, message)¶ Run the action on the message.
Parameters: - conn (imapautofiler.client.Client) – connection to mail server
- mailbox_name (str) – name of the mailbox holding the message
- message_id (str) – ID of the message to process
- message (email.message.Message) – the message object to process
-
report
(conn, src_mailbox, message_id, message)¶ Log a message explaining what action will be taken.
-
-
class
imapautofiler.actions.
Sort
(action_data, cfg)¶ Bases:
imapautofiler.actions.Action
Move the message based on parsing a destination from a header.
The action is indicated with the name
sort
.The action may contain a
header
entry to specify the name of the mail header to examine to find the destination. The default is to use theto
header.The action data may contain a
dest-mailbox-regex
entry for parsing the header value to obtain the destination mailbox name. If the regex has one match group, that substring will be used. If the regex has more than one match group, thedest-mailbox-regex-group
option must specify which group to use (0-based numerical index). The default pattern is([\w-+]+)@
to match the first part of an email address.The action data must contain a
dest-mailbox-base
entry with the base name of the destination mailbox. The actual mailbox name will be constructed by appending the value extracted viadest-mailbox-regex
to thedest-mailbox-base
value. Thedest-mailbox-base
value should contain the mailbox separator character (usually.
) if the desired mailbox is a sub-folder of the name given.The
dest-mailbox-base
may include jinja2 template instructions, which are evaluated before the suffix is added to the base. Refer to the description of themove
action for more details about template evaluation.-
NAME
= 'sort'¶
-
invoke
(conn, src_mailbox, message_id, message)¶ Run the action on the message.
Parameters: - conn (imapautofiler.client.Client) – connection to mail server
- mailbox_name (str) – name of the mailbox holding the message
- message_id (str) – ID of the message to process
- message (email.message.Message) – the message object to process
-
report
(conn, src_mailbox, message_id, message)¶ Log a message explaining what action will be taken.
-
-
class
imapautofiler.actions.
SortMailingList
(action_data, cfg)¶ Bases:
imapautofiler.actions.Sort
Move the message based on the mailing list id.
The action is indicated with the name
sort-mailing-list
.This action is equivalent to the
sort
action with header set tolist-id
anddest-mailbox-regex
set to<?([^.]+)\..*>?
.-
NAME
= 'sort-mailing-list'¶
-
-
class
imapautofiler.actions.
Trash
(action_data, cfg)¶ Bases:
imapautofiler.actions.Move
Move the message to the trashcan.
The action is indicated with the name
trash
.The action expects the global configuration setting
trash-mailbox
.-
NAME
= 'trash'¶
-
-
class
imapautofiler.actions.
Unflag
(action_data, cfg)¶ Bases:
imapautofiler.actions.Action
Remove the flag setting from the message.
The action is indicated with the name
unflag
.-
NAME
= 'unflag'¶
-
invoke
(conn, mailbox_name, message_id, message)¶ Run the action on the message.
Parameters: - conn (imapautofiler.client.Client) – connection to mail server
- mailbox_name (str) – name of the mailbox holding the message
- message_id (str) – ID of the message to process
- message (email.message.Message) – the message object to process
-
report
(conn, mailbox_name, message_id, message)¶ Log a message explaining what action will be taken.
-
-
imapautofiler.actions.
factory
(action_data, cfg)¶ Create an Action instance.
Parameters: - action_data (dict) – portion of configuration describing the action
- cfg (dict) – full configuration data
Using the action type, instantiate an action object that can process a message.