Merge pull request #848 from LukeAmos/issue/814

FIX: Fixes issue #814 added email template for plain text, as to avoid raw HTML ending up in plain text emails.

https://github.com/silverstripe/silverstripe-userforms/issues/814

># HTML is present in the PlainText Body of emails
>
>I only noticed this because we started using PostMark (which seems to reject HTML emails which have HTML in the Plain Text Body). I suspect though that this will make emails more likely to be seen as spam?
>
>I have tracked the issue (I think) back to this line: /code/Control/UserDefinedFormController.php@master#L294
>
>Looks like the HTML template is being used by both.
>
>I have checked and cannot see this issue reported anywhere else. Is it worth doing a PR with a fix?
This commit is contained in:
Dylan Wagstaff 2019-01-16 14:43:46 +13:00 committed by GitHub
commit 85408afdd5
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
4 changed files with 14 additions and 4 deletions

View File

@ -290,8 +290,8 @@ JS
if ($recipients = $this->FilteredEmailRecipients($data, $form)) {
foreach ($recipients as $recipient) {
$email = Email::create()
->setHTMLTemplate('email/SubmittedFormEmail')
->setPlainTemplate('email/SubmittedFormEmail');
->setHTMLTemplate('email/SubmittedFormEmailHtml')
->setPlainTemplate('email/SubmittedFormEmailPlain');
// Merge fields are used for CMS authors to reference specific form fields in email content
$mergeFields = $this->getMergeFieldsMap($emailData['Fields']);

View File

@ -0,0 +1,10 @@
<%-- Note: content is already escaped in UserDefinedFormController::process --%>
$Body.RAW
<% if not $HideFormData %>
*
<% loop $Fields %>
* <% if $Title %>$Title<% else %>$Name<% end_if %>
* $FormattedValue
<% end_loop %>
<% end_if %>

View File

@ -175,8 +175,8 @@ class UserDefinedFormTest extends FunctionalTest
$result = $recipient->getEmailTemplateDropdownValues();
// Installation path can be as a project when testing in Travis, so check partial match
$this->assertContains('email' . DIRECTORY_SEPARATOR . 'SubmittedFormEmail', key($result));
$this->assertSame('SubmittedFormEmail', current($result));
$this->assertContains('email' . DIRECTORY_SEPARATOR . 'SubmittedFormEmailHtml', key($result));
$this->assertSame('SubmittedFormEmailHtml', current($result));
}
public function testEmailTemplateExists()