_ = XLATOR.gettext
ngettext = XLATOR.ngettext
-__version__ = '0.5.0'
+__version__ = '0.5.1'
# =============================================================================
r'DKIM-Signature\s+field\s+added\s+\(s=(?P<selector>\S+), d=(?P<domain>\S+)\)',
re.IGNORECASE)
+ re_pickup = re.compile(r'uid=(?P<uid>\d+)\s+from=<(?P<from>[^>]*)>', re.IGNORECASE)
+
warn_on_parse_error = True
deliver_commands = (
LOG.debug(msg)
return
+ if command == 'postfix/cleanup':
+ m = self.re_pickup.search(message)
+ if m:
+ if postfix_id in self.chain:
+ self.chain[postfix_id].pickup_from = m['from']
+ self.chain[postfix_id].pickup_uid = m['uid']
+ else:
+ msg = _('Did not found Postfix ID {!r} for pickup log entry.').format(
+ postfix_id)
+ if self.warn_on_parse_error:
+ LOG.warn(msg)
+ else:
+ LOG.debug(msg)
+ return
+
if command == 'opendkim':
m = self.re_dkim.search(message)
if m:
_ = XLATOR.gettext
ngettext = XLATOR.ngettext
-__version__ = '0.8.0'
+__version__ = '0.8.1'
LOG = logging.getLogger(__name__)
'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', 'finished',
- 'dkim_selector', 'dkim_domain',
+ 'dkim_selector', 'dkim_domain', 'pickup_uid', 'pickup_from',
)
# -------------------------------------------------------------------------
return
self._message_id = val
+ # -----------------------------------------------------------
+ @property
+ def pickup_from(self):
+ """Return the From address of a picked up mail, which was sended via sendmail."""
+ return self._pickup_from
+
+ @pickup_from.setter
+ def pickup_from(self, value):
+ if value is None:
+ self._pickup_from = None
+ return
+
+ val = str(value).strip()
+ if val == '':
+ self._pickup_from = None
+ return
+ self._pickup_from = val
+
+ # -----------------------------------------------------------
+ @property
+ def pickup_uid(self):
+ """Return the numeric Uid of the process, which was sending a mail via sendmail.."""
+ return self._pickup_uid
+
+ @pickup_uid.setter
+ def pickup_uid(self, value):
+ if value is None:
+ self._pickup_uid = None
+ return
+
+ if isinstance(value, int):
+ self._pickup_uid = value
+ return
+ try:
+ val = int(value)
+ self._pickup_uid = val
+ except ValueError as e:
+ msg = _('Could not interprete the Uid of a picked up mail {a!r}: {e}').format(
+ a=val, e=e)
+ if self.warn_on_parse_error:
+ LOG.warn(msg)
+ else:
+ LOG.debug(msg)
+ self._pickup_uid = None
+
# -----------------------------------------------------------
@property
def postfix_id(self):