Skip to content

Beautiful Open-Source Form Builder

fix hidden email field in integration (#845)

Chirag Chhatralabaef02520d87
diff --git a/api/app/Integrations/Handlers/EmailIntegration.php b/api/app/Integrations/Handlers/EmailIntegration.php
index 60ee1d65a..affbe9d49 100644
--- a/api/app/Integrations/Handlers/EmailIntegration.php
+++ b/api/app/Integrations/Handlers/EmailIntegration.php
@@ -96,7 +96,7 @@ class EmailIntegration extends AbstractIntegrationHandler
}
if ($this->form->is_pro) { // For Send to field Mentions are Pro feature
- $formatter = (new FormSubmissionFormatter($this->form, $this->submissionData))->outputStringsOnly();
+ $formatter = (new FormSubmissionFormatter($this->form, $this->submissionData))->outputStringsOnly()->showHiddenFields();
$parser = new MentionParser($this->integrationData?->send_to, $formatter->getFieldsWithValue());
$sendTo = $parser->parseAsText();
} else {
diff --git a/api/tests/Feature/Forms/EmailNotificationTest.php b/api/tests/Feature/Forms/EmailNotificationTest.php
index 23461ffb5..668c22aa1 100644
--- a/api/tests/Feature/Forms/EmailNotificationTest.php
+++ b/api/tests/Feature/Forms/EmailNotificationTest.php
@@ -284,3 +284,44 @@ it('uses exact email address without timestamp in self-hosted mode', function ()
// In self-hosted mode, the email should be exactly as configured without timestamp
expect($renderedMail->from[0])->toBe('[email protected]');
});
+
+it('send email with hidden field as mention to send email', function () {
+ $user = $this->actingAsProUser();
+ $workspace = $this->createUserWorkspace($user);
+ $form = $this->createForm($user, $workspace);
+
+ $emailProperty = collect($form->properties)->first(function ($property) {
+ return $property['type'] == 'email';
+ });
+
+ $integrationData = $this->createFormIntegration('email', $form->id, [
+ 'send_to' => '<span mention-field-id="' . $emailProperty['id'] . '" mention-field-name="' . $emailProperty['name'] . '" mention-fallback="" contenteditable="false" mention="true">' . $emailProperty['name'] . '</span>',
+ 'sender_name' => 'OpnForm',
+ 'subject' => 'New form submission',
+ 'email_content' => 'Hello there 👋 <br>Test body',
+ 'include_submission_data' => true,
+ 'include_hidden_fields_submission_data' => false,
+ 'reply_to' => null,
+ ]);
+
+ $formData = [
+ $emailProperty['id'] => '[email protected]',
+ ];
+
+ Notification::fake();
+
+ $this->postJson(route('forms.answer', $form->slug), $formData)
+ ->assertSuccessful()
+ ->assertJson([
+ 'type' => 'success',
+ 'message' => 'Form submission saved.',
+ ]);
+
+ Notification::assertSentTo(
+ new AnonymousNotifiable(),
+ FormEmailNotification::class,
+ function (FormEmailNotification $notification, $channels, $notifiable) {
+ return $notifiable->routes['mail'] === '[email protected]';
+ }
+ );
+});