mail: ajoute fonction send_template
Pour tout faire en une seule commande
This commit is contained in:
parent
a742a6847c
commit
ab2cf5b6e4
1 changed files with 15 additions and 0 deletions
|
@ -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()
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue