misc: allow comma separated list of emails as recipient (#22118)

This commit is contained in:
Frédéric Péters 2018-02-26 14:44:46 +01:00
parent a243987056
commit 9222d257e2
2 changed files with 29 additions and 0 deletions

View File

@ -858,6 +858,14 @@ def test_email(pub, emails):
assert emails.count() == 1
assert emails.get('foobar')['email_rcpt'] == ['foo@localhost', 'bar@localhost']
# multiple recipients in a single computed string
emails.empty()
item.to = ['="foo@localhost, bar@localhost"']
item.perform(formdata)
get_response().process_after_jobs()
assert emails.count() == 1
assert emails.get('foobar')['email_rcpt'] == ['foo@localhost', 'bar@localhost']
# string as recipient
emails.empty()
item.to = 'xyz@localhost'
@ -866,6 +874,22 @@ def test_email(pub, emails):
assert emails.count() == 1
assert emails.get('foobar')['email_rcpt'] == ['xyz@localhost']
# string as recipient (but correctly set in a list)
emails.empty()
item.to = ['xyz@localhost']
item.perform(formdata)
get_response().process_after_jobs()
assert emails.count() == 1
assert emails.get('foobar')['email_rcpt'] == ['xyz@localhost']
# multiple recipients in a static string
emails.empty()
item.to = ['foo@localhost, bar@localhost']
item.perform(formdata)
get_response().process_after_jobs()
assert emails.count() == 1
assert emails.get('foobar')['email_rcpt'] == ['foo@localhost', 'bar@localhost']
# invalid recipient
emails.empty()
item.to = ['=foobar']

View File

@ -2208,6 +2208,11 @@ class SendmailWorkflowStatusItem(WorkflowStatusItem):
if isinstance(dest, list):
addresses.extend(dest)
continue
elif isinstance(dest, basestring) and ',' in dest:
# if the email contains a comma consider it as a serie of
# emails
addresses.extend([x.strip() for x in dest.split(',')])
continue
if '@' in str(dest):
addresses.append(dest)