FIX Fix support address list in email address fields (#707)

This commit is contained in:
Raissa North 2018-01-29 09:56:44 +13:00 committed by Robbie Averill
parent 9a09873e7d
commit 77c47a38fa
3 changed files with 18 additions and 5 deletions

View File

@ -323,12 +323,12 @@ JS
$email->addData($key, $value);
}
$email->setFrom($recipient->EmailFrom);
$email->setTo($recipient->EmailAddress);
$email->setFrom(explode(',', $recipient->EmailFrom));
$email->setTo(explode(',', $recipient->EmailAddress));
$email->setSubject($recipient->EmailSubject);
if ($recipient->EmailReplyTo) {
$email->setReplyTo($recipient->EmailReplyTo);
$email->setReplyTo(explode(',', $recipient->EmailReplyTo));
}
// check to see if they are a dynamic reply to. eg based on a email field a user selected
@ -336,7 +336,7 @@ JS
$submittedFormField = $submittedFields->find('Name', $recipient->SendEmailFromField()->Name);
if ($submittedFormField && is_string($submittedFormField->Value)) {
$email->setReplyTo($submittedFormField->Value);
$email->setReplyTo(explode(',', $submittedFormField->Value));
}
}
// check to see if they are a dynamic reciever eg based on a dropdown field a user selected
@ -344,7 +344,7 @@ JS
$submittedFormField = $submittedFields->find('Name', $recipient->SendEmailToField()->Name);
if ($submittedFormField && is_string($submittedFormField->Value)) {
$email->setTo($submittedFormField->Value);
$email->setTo(explode(',', $submittedFormField->Value));
}
}

View File

@ -89,6 +89,13 @@ class UserDefinedFormControllerTest extends FunctionalTest
// check to see if the user was redirected (301)
$this->assertEquals($response->getStatusCode(), 302);
$this->assertStringEndsWith('finished#uff', $response->getHeader('Location'));
// check that multiple email addresses are supported in to and from
$this->assertEmailSent(
'test1@example.com; test2@example.com',
'test3@example.com; test4@example.com',
'Test Email'
);
}
public function testValidation()

View File

@ -264,6 +264,11 @@ SilverStripe\UserForms\Model\Recipient\EmailRecipient:
EmailSubject: Email Subject
EmailFrom: no-reply@example.com
multiple-email-list:
EmailAddress: test1@example.com, test2@example.com
EmailSubject: Test Email
EmailFrom: test3@example.com, test4@example.com
SilverStripe\UserForms\Model\UserDefinedForm:
basic-form-page:
Content: '<p>Here is my form</p><p>$UserDefinedForm</p><p>Thank you for filling it out</p>'
@ -275,6 +280,7 @@ SilverStripe\UserForms\Model\UserDefinedForm:
- =>SilverStripe\UserForms\Model\Recipient\EmailRecipient.recipient-1
- =>SilverStripe\UserForms\Model\Recipient\EmailRecipient.no-html
- =>SilverStripe\UserForms\Model\Recipient\EmailRecipient.no-data
- =>SilverStripe\UserForms\Model\Recipient\EmailRecipient.multiple-email-list
page-with-group:
Content: 'Page with group'