aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorVG <vg@devys.org>2016-05-31 23:01:45 +0200
committerVG <vg@devys.org>2016-05-31 23:01:45 +0200
commit791451615a8e34f45b032d1208fc4a4c9a391ce4 (patch)
tree0444718ea58505f4ae130360999cd80081452c4c
parent34251fd9b354710839b55b1120684071bb40e363 (diff)
downloadcliml-791451615a8e34f45b032d1208fc4a4c9a391ce4.tar.gz
climl-791451615a8e34f45b032d1208fc4a4c9a391ce4.tar.bz2
climl-791451615a8e34f45b032d1208fc4a4c9a391ce4.zip
add first code for sending mails by smtp
-rw-r--r--climl/hooks.py9
1 files changed, 9 insertions, 0 deletions
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()