# Own modules
from ..postfix_chain import PostfixLogchainInfo
+from ..postfix_chain import SmtpAction
from ..xlate import XLATOR
LOG = logging.getLogger(__name__)
_ = XLATOR.gettext
ngettext = XLATOR.ngettext
-__version__ = '0.4.0'
+__version__ = '0.4.1'
# =============================================================================
'into chain.')
self.chain[postfix_id] = self.active_smtpd_pid[pid]
+ if command == 'postfix/smtp' and pid:
+ self.eval_smtp_action(
+ postfix_id=postfix_id, timestamp=timestamp, host=host, pid=pid,
+ message=message)
+ return
+
if postfix_id in self.chain:
m = self.re_message_id.search(message)
if m:
if message.lower() == 'removed' and postfix_id in self.chain:
self.chain[postfix_id].end = timestamp
+ self.chain[postfix_id].finished = True
return
if smtpd_done:
msg = f'Evaluating further entry of {command!r} for Postfix Id {postfix_id!r}: '
LOG.debug(msg + message)
+ # -------------------------------------------------------------------------
+ def eval_smtp_action(
+ self, postfix_id, timestamp=None, host=None, pid=None, message=None):
+ """Evaluate a postfix/smtp action log line."""
+ if postfix_id not in self.chain:
+ LOG.warn(_('Postfix transaction {!r} does not exists.').format(postfix_id))
+ return
+
+ action = SmtpAction.from_log_entry(
+ timestamp=timestamp, pid=pid, message=message, verbose=self.verbose)
+
+ self.chain[postfix_id].add_smtp_action(action)
+
# =========================================================================
if __name__ == '__main__':
# Third party modules
from fb_tools.common import pp
+from fb_tools.common import to_bool
from fb_tools.errors import InvalidMailAddressError
from fb_tools.mailaddress import MailAddress
from fb_tools.obj import FbGenericBaseObject
_ = XLATOR.gettext
ngettext = XLATOR.ngettext
-__version__ = '0.7.1'
+__version__ = '0.7.2'
LOG = logging.getLogger(__name__)
attributes = (
'client_host', 'client_addr', 'start', 'end', 'message_id', 'postfix_id', 'ehlo',
'starttls', 'sent_quit', 'auth', 'commands', 'rcpt', 'data', 'mail', 'from_address',
- 'smtpd_pid', 'mailhost', 'tls_version', 'tls_cipher', 'size', 'nr_rcpt',
+ 'smtpd_pid', 'mailhost', 'tls_version', 'tls_cipher', 'size', 'nr_rcpt', 'finished',
)
# -------------------------------------------------------------------------
priv_name = '_' + attr
setattr(self, priv_name, None)
+ self._finished = False
+
self.smtp_actions = []
if smtp_actions:
self.set_smtp_actions(smtp_actions)
return
self._end = val
+ # -----------------------------------------------------------
+ @property
+ def finished(self):
+ """
+ Return, whether the Postfix transaction was finished.
+
+ It means also, taht the mail was removed from queue.
+ """
+ return self._finished
+
+ @finished.setter
+ def finished(self, value):
+ self._finished = to_bool(value)
+
# -----------------------------------------------------------
@property
def from_address(self):