Skip to content

Beautiful Open-Source Form Builder

fix email reply to issue (#326)

Favour Olayinka8a067012e5b5
diff --git a/app/Mail/Forms/SubmissionConfirmationMail.php b/app/Mail/Forms/SubmissionConfirmationMail.php
index 93a82ef17..52ec21f5a 100644
--- a/app/Mail/Forms/SubmissionConfirmationMail.php
+++ b/app/Mail/Forms/SubmissionConfirmationMail.php
@@ -63,6 +63,9 @@ class SubmissionConfirmationMail extends OpenFormMail implements ShouldQueue
{
$replyTo = Arr::get((array) $this->event->form->notification_settings, 'confirmation_reply_to', null);
- return $replyTo ?? $default;
+ if ($replyTo && filter_var($replyTo, FILTER_VALIDATE_EMAIL)) {
+ return $replyTo;
+ }
+ return $default;
}
}
diff --git a/tests/Feature/Forms/ConfirmationEmailTest.php b/tests/Feature/Forms/ConfirmationEmailTest.php
index 6776b7b65..8e03a6929 100644
--- a/tests/Feature/Forms/ConfirmationEmailTest.php
+++ b/tests/Feature/Forms/ConfirmationEmailTest.php
@@ -110,3 +110,31 @@ it('does not send a confirmation email if not needed', function () {
}
);
});
+
+it('does send a confirmation email even when reply to is broken', function () {
+ $user = $this->actingAsProUser();
+ $workspace = $this->createUserWorkspace($user);
+ $form = $this->createForm($user, $workspace, [
+ 'send_submission_confirmation' => true,
+ 'notifications_include_submission' => true,
+ 'notification_sender' => 'Custom Sender',
+ 'notification_subject' => 'Test subject',
+ 'notification_body' => 'Test body',
+ 'notification_settings' => [
+ 'confirmation_reply_to' => 'invalid-email',
+ ]
+ ]);
+
+ $emailProperty = collect($form->properties)->first(function ($property) {
+ return $property['type'] == 'email';
+ });
+ $formData = [
+ $emailProperty['id'] => '[email protected]',
+ ];
+ $event = new \App\Events\Forms\FormSubmitted($form, $formData);
+ $mailable = new SubmissionConfirmationMail($event);
+ $mailable->assertSeeInHtml('Test body')
+ ->assertSeeInHtml('As a reminder, here are your answers:')
+ ->assertSeeInHtml('You are receiving this email because you answered the form:')
+ ->assertHasReplyTo($user->email); // Even though reply to is wrong, it should use the user's email
+});