The imapautofiler.client Module

Mail client API.

class imapautofiler.client.Client(cfg)

Bases: object

close()

Close the connection, flushing any pending changes.

copy_message(src_mailbox, dest_mailbox, message_id, message)

Create a copy of the message in the destination mailbox.

Parameters:
  • src_mailbox (str) – name of the source mailbox
  • dest_mailbox (src) – name of the destination mailbox
  • message_id (str) – ID of the message to copy
  • message (email.message.Message) – message instance
delete_message(src_mailbox, message_id, message)

Remove the message.

Parameters:
  • src_mailbox (str) – name of the source mailbox
  • message_id (str) – ID of the message to copy
  • message (email.message.Message) – message instance
expunge()

Flush any pending changes.

list_mailboxes()

Return a list of mailbox names.

mailbox_iterate(mailbox_name)

Iterate over messages from the mailbox.

Produces tuples of (message_id, message).

move_message(src_mailbox, dest_mailbox, message_id, message)

Move the message from the source to the destination mailbox.

Parameters:
  • src_mailbox (str) – name of the source mailbox
  • dest_mailbox (src) – name of the destination mailbox
  • message_id (str) – ID of the message to copy
  • message (email.message.Message) – message instance
set_flagged(src_mailbox, message_id, message, is_flagged)

Manage the “flagged” flag for the message.

If is_flagged is True, ensure the message is flagged. Otherwise, ensure it is not.

Parameters:
  • src_mailbox (str) – name of the source mailbox
  • message_id (str) – ID of the message to copy
  • is_flagged – whether to flag the message
set_read(src_mailbox, message_id, message, is_read)

Manage the “read” flag for the message.

If is_read is True, ensure the message is read. Otherwise, ensure it is not.

Parameters:
  • src_mailbox (str) – name of the source mailbox
  • message_id (str) – ID of the message to copy
  • is_read – whether the message should be marked read
class imapautofiler.client.IMAPClient(cfg)

Bases: imapautofiler.client.Client

close()

Close the connection, flushing any pending changes.

copy_message(src_mailbox, dest_mailbox, message_id, message)

Create a copy of the message in the destination mailbox.

Parameters:
  • src_mailbox (str) – name of the source mailbox
  • dest_mailbox (src) – name of the destination mailbox
  • message_id (str) – ID of the message to copy
  • message (email.message.Message) – message instance
delete_message(src_mailbox, message_id, message)

Remove the message.

Parameters:
  • src_mailbox (str) – name of the source mailbox
  • message_id (str) – ID of the message to copy
  • message (email.message.Message) – message instance
expunge()

Flush any pending changes.

list_mailboxes()

Return a list of folder names.

mailbox_iterate(mailbox_name)

Iterate over messages from the mailbox.

Produces tuples of (message_id, message).

set_flagged(src_mailbox, message_id, message, is_flagged)

Manage the “flagged” flag for the message.

If is_flagged is True, ensure the message is flagged. Otherwise, ensure it is not.

Parameters:
  • src_mailbox (str) – name of the source mailbox
  • message_id (str) – ID of the message to copy
  • is_flagged – whether to flag the message
set_read(src_mailbox, message_id, message, is_read)

Manage the “read” flag for the message.

If is_read is True, ensure the message is read. Otherwise, ensure it is not.

Parameters:
  • src_mailbox (str) – name of the source mailbox
  • message_id (str) – ID of the message to copy
  • is_read – whether the message should be marked read
class imapautofiler.client.MaildirClient(cfg)

Bases: imapautofiler.client.Client

close()

Close the connection, flushing any pending changes.

copy_message(src_mailbox, dest_mailbox, message_id, message)

Create a copy of the message in the destination mailbox.

Parameters:
  • src_mailbox (str) – name of the source mailbox
  • dest_mailbox (src) – name of the destination mailbox
  • message_id (str) – ID of the message to copy
  • message (email.message.Message) – message instance
delete_message(src_mailbox, message_id, message)

Remove the message.

Parameters:
  • src_mailbox (str) – name of the source mailbox
  • message_id (str) – ID of the message to copy
  • message (email.message.Message) – message instance
expunge()

Flush any pending changes.

list_mailboxes()

Return a list of mailbox names.

mailbox_iterate(mailbox_name)

Iterate over messages from the mailbox.

Produces tuples of (message_id, message).

set_flagged(src_mailbox, message_id, message, is_flagged)

Manage the “flagged” flag for the message.

If is_flagged is True, ensure the message is flagged. Otherwise, ensure it is not.

Parameters:
  • src_mailbox (str) – name of the source mailbox
  • message_id (str) – ID of the message to copy
  • is_flagged – whether to flag the message
set_read(src_mailbox, message_id, message, is_flagged)

Manage the “read” flag for the message.

If is_read is True, ensure the message is read. Otherwise, ensure it is not.

Parameters:
  • src_mailbox (str) – name of the source mailbox
  • message_id (str) – ID of the message to copy
  • is_read – whether the message should be marked read
imapautofiler.client.open_connection(cfg)

Open a connection to the mail server.