all repos — listfix @ 46f9fcea2efeeb508727cf9b1f37f0a44f6e2e3e

Postfix Mailing List Software; Maintained on behalf the of Agency Economy Incorporated NFP.

Add logging

	modified:   listfix_filter.py
Brian Barto bartobrian@gmail.com
Mon, 14 Mar 2022 21:07:00 -0400
commit

46f9fcea2efeeb508727cf9b1f37f0a44f6e2e3e

parent

71bf87298704ef24cc3769bfe14d20b4459e3077

1 files changed, 22 insertions(+), 2 deletions(-)

jump to
M listfix_filter.pylistfix_filter.py

@@ -78,6 +78,21 @@ for line in email_contents:

p.write(line) p.close() +def log_info(sender, recipient, lines): + + f = open("/tmp/listfix_log.txt", "a") + f.write(f"Postfix Sender: {sender}\n") + f.write(f"Postfix Recipient: {recipient}\n") + + for line in lines: + if (re_header_end.match(line)): + break + + f.write(line) + + f.write("\n") + f.close() + ######################## ## Main Program

@@ -99,6 +114,7 @@ list_name = None

list_domain = None email = [] email_filtered = [] +logging = True ## Get/check args

@@ -108,7 +124,6 @@ recipient = sys.argv[2]

else: raise ValueError('Missing or Invalid Arguments') - ## Get email content for line in sys.stdin:

@@ -116,6 +131,11 @@ email.append(line)

if (len(email) == 0): raise ValueError('Missing Piped Data') +## Logging + +if (logging): + log_info(sender, recipient, email) + ## Check if this is an auto-reply auto_sub_line = get_header(email, "Auto-Submitted")

@@ -150,7 +170,7 @@

## If this is already filtered, add skip header and resubmit if (re.search(list_email, from_line)): - email.insert(0, "List-Skip-Filter: yes\n") + email.insert(0, "Listfix-Skip-Filter: yes\n") send_email(list_email, email) exit()