comparison src/tools/email.py @ 2304:666ad9de044c

core (tools/email): an unicode "to" email (instead of a list) can now be used
author Goffi <goffi@goffi.org>
date Wed, 05 Jul 2017 15:02:52 +0200
parents 968b0d13bcc7
children 8b37a62336c3
comparison
equal deleted inserted replaced
2303:37887b5acb25 2304:666ad9de044c
29 29
30 30
31 def sendEmail(host, to_emails, subject=u'', body=u'', from_email=None): 31 def sendEmail(host, to_emails, subject=u'', body=u'', from_email=None):
32 """send an email using SàT configuration 32 """send an email using SàT configuration
33 33
34 @param to_emails(list[unicode]): list of recipients 34 @param to_emails(list[unicode], unicode): list of recipients
35 if unicode, it will be split to get emails
35 @param subject(unicode): subject of the message 36 @param subject(unicode): subject of the message
36 @param body(unicode): body of the message 37 @param body(unicode): body of the message
37 @param from_email(unicode): address of the sender 38 @param from_email(unicode): address of the sender
38 @return (D): same as smtp.sendmail 39 @return (D): same as smtp.sendmail
39 """ 40 """
41 if isinstance(to_emails, basestring):
42 to_emails = to_emails.split()
40 email_host = host.memory.getConfig(None, u'email_server') or u'localhost' 43 email_host = host.memory.getConfig(None, u'email_server') or u'localhost'
41 email_from = host.memory.getConfig(None, u'email_from') 44 email_from = host.memory.getConfig(None, u'email_from')
42 if email_from is None: 45 if email_from is None:
43 # we suppose that email domain and XMPP domain are identical 46 # we suppose that email domain and XMPP domain are identical
44 domain = host.memory.getConfig(None, u'xmpp_domain', u'example.net') 47 domain = host.memory.getConfig(None, u'xmpp_domain', u'example.net')