def scan_postfix_smtpd_line(date, log, collector):
 m = re.match('NOQUEUE: reject: RCPT from .*?: (.*?); from=<(.*?)> to=<(.*?)>', log)
 if m:
  (message, sender, recipient) = m.groups()
  if (recipient in collector['real_mail_addresses']):
   if ('Recipient address rejected: Greylisted' in message):
    return
   m = re.search('Client host \\[(.*?)\\] blocked using zen.spamhaus.org; (.*)', message)
   if m:
    message = ('ip blocked: ' + m.group(2))
   m = re.search('Sender address \\[.*@(.*)\\] blocked using dbl.spamhaus.org; (.*)', message)
   if m:
    message = ('domain blocked: ' + m.group(2))
   collector['rejected-mail'].setdefault(recipient, []).append((date, sender, message))

def scan_postfix_smtpd_line ( date , log , collector ) : m = re . match ( 'NOQUEUE: reject: RCPT from .*?: (.*?); from=<(.*?)> to=<(.*?)>' , log ) if m : ( message , sender , recipient ) = m . groups ( ) if ( recipient in collector [ 'real_mail_addresses' ] ) : if ( 'Recipient address rejected: Greylisted' in message ) : return m = re . search ( 'Client host \\[(.*?)\\] blocked using zen.spamhaus.org; (.*)' , message ) if m : message = ( 'ip blocked: ' + m . group ( 2 ) ) m = re . search ( 'Sender address \\[.*@(.*)\\] blocked using dbl.spamhaus.org; (.*)' , message ) if m : message = ( 'domain blocked: ' + m . group ( 2 ) ) collector [ 'rejected-mail' ] . setdefault ( recipient , [ ] ) . append ( ( date , sender , message ) )
scan a postfix smtpd log line and extract interesting data .