diff options
Diffstat (limited to 'climl/hooks.py')
-rw-r--r-- | climl/hooks.py | 15 |
1 files changed, 6 insertions, 9 deletions
diff --git a/climl/hooks.py b/climl/hooks.py index fcc43f4..a521376 100644 --- a/climl/hooks.py +++ b/climl/hooks.py @@ -3,7 +3,7 @@ from . import interface def hook_extract_listname(context): - lines = content.split(b'\n') + lines = context['content'].split(b'\n') for line in lines: print('line: ', line) if line.startswith(b'Delivered-To: '): @@ -27,23 +27,18 @@ def hook_process_subscribe_queries(context): def hook_generate_rcpt_list(context): - print(1) listname = context.get('listname', None) - print(2) if not listname: raise interface.HookStopIteration('list name not found') - print(3) recipients_filename = ''.join([listname, '-recipents.txt']) - print(4) try: with open(recipients_filename, encoding='utf8') as fi: recipients = [recipient for recipient in fi] context['recipients'] = recipients - print(5) except FileNotFoundError as e: n = interface.HookAbortError('recipients list not found') - n.args.append({'listname': listname, - 'recipients_filename': recipients_filename}) + n.args += ({'listname': listname, + 'recipients_filename': recipients_filename}, ) raise n from e @@ -58,5 +53,7 @@ def hook_send_all(context): smtp_server = smtplib.SMTP(context.conf.get('smtp.server')) #smtp_server.set_debuglevel(1) - smtp_server.sendmail(listaddress, context['recipients'], content) + smtp_server.sendmail(listaddress, + context['recipients'], + context['content']) smtp_server.quit() |