From 791451615a8e34f45b032d1208fc4a4c9a391ce4 Mon Sep 17 00:00:00 2001 From: VG Date: Tue, 31 May 2016 23:01:45 +0200 Subject: add first code for sending mails by smtp --- climl/hooks.py | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/climl/hooks.py b/climl/hooks.py index c4840fd..8311da4 100644 --- a/climl/hooks.py +++ b/climl/hooks.py @@ -1,3 +1,4 @@ +import smtplib from . import interface @@ -30,7 +31,15 @@ def hook_generate_rcpt_list(context, content): def hook_send_all(context, content): + listaddress = context.get('listaddress', None) + if not listaddress: + raise interface.HookStopIteration('list address not found') recipients = context.get('recipients', None) if not recipients: raise interface.HookStopIteration() # TODO: how to send emails here ? + + smtp_server = smtplib.SMTP(context.get('smtp.server')) + #smtp_server.set_debuglevel(1) + smtp_server.sendmail(listaddress, context['recipients'], content) + smtp_server.quit() -- cgit v1.2.3