pymailq.control – Mails queue adminitrative operations¶
The control module define a basic python class to simplify
administrative operations against the mails queue. This module is mainly based
on the postsuper administrative tool functionnalities.
QueueControl Objects¶
- class
control.QueueControl[source]¶Postfix queue control using postsuper command.
The
QueueControlinstance defines the following attributes:
use_sudo¶Boolean to control the use of sudo to invoke Postfix command. Default is
False
postsuper_cmd¶Postfix command and arguments
list()for mails queue administrative operations. Default is["postsuper"]
known_operations¶Known Postfix administrative operations
dictto associate operations to command arguments. Known associations are:delete: -d hold: -h release: -H requeue: -rWarning
Default known associations are provided for the default mails queue administrative command postsuper.
See also
- Postfix manual:
- postsuper – Postfix superintendent
The
QueueControlinstance provides the following methods:
- static
QueueControl.get_operation_cmd(operation)[source]¶Get operation related command from configuration
This method use Postfix administrative commands defined in
pymailq.CONFIGattribute under the key ‘list_queue’. Command and arguments list is build on call with the configuration data.Command keys are built with the
operationargument suffixed with_message. Example:hold_messagefor the hold command.
Parameters: operation (str) – Operation name Returns: Command and arguments as listRaises: KeyError – Operation is unknown
QueueControl._operate(*args, **kwargs)[source]¶Generic method to lead operations messages from postfix mail queue.
Operations can be one of Postfix known operations stored in PyMailq module configuration.
Parameters:
- operation (str) – Known operation from
pymailq.CONFIG.- messages (list) – List of
Returns: Command’s stderr output lines
Return type:
list()
QueueControl.delete_messages(messages)[source]¶Delete several messages from postfix mail queue.
This method is a
partial()wrapper on_operate(). Passed operation isdelete
QueueControl.hold_messages(messages)[source]¶Hold several messages from postfix mail queue.
This method is a
partial()wrapper on_operate(). Passed operation ishold
QueueControl.release_messages(messages)[source]¶Release several messages from postfix mail queue.
This method is a
partial()wrapper on_operate(). Passed operation isrelease
QueueControl.requeue_messages(messages)[source]¶Requeue several messages from postfix mail queue.
This method is a
partial()wrapper on_operate(). Passed operation isrequeue