misc: allow comma separated list of emails as recipient (#22118)
This commit is contained in:
parent
a243987056
commit
9222d257e2
|
@ -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']
|
||||
|
|
|
@ -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)
|
||||
|
|
Loading…
Reference in New Issue