mail: ajoute fonction send_template

Pour tout faire en une seule commande
This commit is contained in:
Daniel STAN 2015-04-05 14:43:28 +02:00
parent a742a6847c
commit ab2cf5b6e4

View file

@ -243,5 +243,20 @@ class ServerConnection(object):
return
self._conn.sendmail(From, to, mail)
def send_template(self, tpl_name, data):
"""Envoie un mail à partir d'un template.
`data` est un dictionnaire contenant entre
"""
From = data.get('from', '')
adh = data.get('adh', data.get('proprio', ''))
to = data.get('to', adh.get_mail())
if to is None:
print "No valid recipient mail. Aborting."
return
# TODO: get lang toussa
body = generate(tpl_name, data).as_string()
self.sendmail(to, From, body)
def __exit__(self, type, value, traceback):
self._conn.quit()