Answers.Body: <p>Okay I got a response from the Solspace team, mentioning that they dont have this feature.</p>
  <p>I have made a workaround and build a module for Craft, listening to the &quot;<a href="https://docs.solspace.com/craft/freeform/v3/developer/submission-events.html#before-a-submission-is-submitted" rel="nofollow noreferrer">After a submission is submitted</a>&quot; event.</p>
  <p>This is what I did:</p>
  <pre><code> Event::on(
          SubmissionsService::class,
          SubmissionsService::EVENT_AFTER_SUBMIT,
          function (SubmitEvent $event) {
              $form = $event-&gt;getForm();
  
              if ($form-&gt;getLayout()-&gt;getFieldByHandle('00N6F00000EZWfQ')-&gt;getValue()) { // check if checkbox is checked
                  $email = $form-&gt;getLayout()-&gt;getFieldByHandle('Email')-&gt;getValueAsString();
  
                  $html = '&lt;h2&gt;We have received your email&lt;/h2&gt;';
                  $html .= &quot;&lt;p&gt;We would like to acknowledge that we have received your enquiry. A member of our staff will be reviewing your enquiry and will send you a personal response.&lt;/p&gt;&quot;;
                  $html .= &quot;&lt;p&gt;Thank you for your patience.&lt;/p&gt;&quot;;
                  $html .= &quot;&lt;p&gt;Sincerely,&lt;/p&gt;&quot;;
                  $html .= &quot;&lt;p&gt;&quot; . getenv('DEFAULT_SITE_NAME') . &quot;&lt;/p&gt;&quot;;
                  $html .= &quot;&lt;hr&gt;&quot;;
  
                  $html .= &quot;&lt;p&gt;&lt;i&gt;Copy of your enquiry attached &lt;/i&gt;&lt;/p&gt;&quot;;
                  $html .= '&lt;ul&gt;';
                  foreach ($form-&gt;getLayout()-&gt;getFields() as $field) {
  
                      if ($field-&gt;getType() == 'hidden' || $field-&gt;getType() == 'submit') {
                          // Dont include them
                      } else {
                          $html .= '&lt;li&gt;&lt;i&gt;' . $field-&gt;getLabel() . &quot;: &quot; . $field-&gt;getValueAsString() . &quot;&lt;/i&gt;&lt;/li&gt;&quot;;
                      }
  
                  }
  
                  $html .= '&lt;/ul&gt;';
  
                  $subject = &quot;Enquiry received - [&quot; . $form-&gt;getName() . &quot;]&quot;;
  
                  $this-&gt;sendMail($html, $subject, $email);
              }
  
          }
      );
  </code></pre>
  <p>And my function to send emails:</p>
  <pre><code> private function sendMail($html, $subject, $mail = null): bool
  {
      $message = new Message();
  
      $message-&gt;setFrom(getenv('SYSTEM_EMAIL_ADDRESS'));
      $message-&gt;setTo($mail);
      $message-&gt;setSubject($subject);
      $message-&gt;setHtmlBody($html);
      
  
      return Craft::$app-&gt;mailer-&gt;send($message);
  }
  </code></pre>
  <p>Hope this is useful for someone</p>
  <p>Happy coding :)</p>
  
Answers.ContentLicense: CC BY-SA 4.0
Answers.CreationDate: 2021-06-21T22:56:08.523Z
Answers.LastActivityDate: 2021-06-21T22:56:08.523Z
Answers.UserDisplayName: Paloma Martinez
Body: <p>I'm developing a site in Craft 3.
  I have added Freeform PRO to it. I am just wondering if this is possible:</p>
  <p>I have created a form, and I want all the notifications of submissions sent to the admin (which is doing good), but I also want to send a notification to the user that is completing the form in the frontend based on a field's value.</p>
  <p>Basically, I have added a checkbox labelled as &quot;<em>I want to receive a copy of this enquiry.</em>&quot;, so if this is checked, then send an email to the person who is submitting the form.</p>
  <p>I'm thinking of different options to do this, like listening to the submission event and check if the checkbox is ticked, but I am looking first at the docs of Freeform but I think that scenario is not supported (yet) ?</p>
  
Tags: <craft3><emails><plugin-freeform><freeform>
Title: Freeform plugin: dynamic recipient
ThreadText: # Freeform plugin: dynamic recipient
  
  (Asked by: username_0 on 2021-06-21)
  
  I'm developing a site in Craft 3.
  I have added Freeform PRO to it. I am just wondering if this is possible:
  
  I have created a form, and I want all the notifications of submissions sent to the admin (which is doing good), but I also want to send a notification to the user that is completing the form in the frontend based on a field's value.
  
  Basically, I have added a checkbox labelled as "*I want to receive a copy of this enquiry.*", so if this is checked, then send an email to the person who is submitting the form.
  
  I'm thinking of different options to do this, like listening to the submission event and check if the checkbox is ticked, but I am looking first at the docs of Freeform but I think that scenario is not supported (yet) ?
  
  **Tags:** craft3, emails, plugin-freeform, freeform
  
  
  ---
  
  ## 1 answers
  
  ### Answer by username_0 on 2021-06-21. Score: 1
  
  Okay I got a response from the Solspace team, mentioning that they dont have this feature.
  
  I have made a workaround and build a module for Craft, listening to the "[After a submission is submitted](https://docs.solspace.com/craft/freeform/v3/developer/submission-events.html#before-a-submission-is-submitted)" event.
  
  This is what I did:
  
  ```
   Event::on(
          SubmissionsService::class,
          SubmissionsService::EVENT_AFTER_SUBMIT,
          function (SubmitEvent $event) {
              $form = $event->getForm();
  
              if ($form->getLayout()->getFieldByHandle('00N6F00000EZWfQ')->getValue()) { // check if checkbox is checked
                  $email = $form->getLayout()->getFieldByHandle('Email')->getValueAsString();
  
                  $html = '<h2>We have received your email</h2>';
                  $html .= "<p>We would like to acknowledge that we have received your enquiry. A member of our staff will be reviewing your enquiry and will send you a personal response.</p>";
                  $html .= "<p>Thank you for your patience.</p>";
                  $html .= "<p>Sincerely,</p>";
                  $html .= "<p>" . getenv('DEFAULT_SITE_NAME') . "</p>";
                  $html .= "<hr>";
  
                  $html .= "<p><i>Copy of your enquiry attached </i></p>";
                  $html .= '<ul>';
                  foreach ($form->getLayout()->getFields() as $field) {
  
                      if ($field->getType() == 'hidden' || $field->getType() == 'submit') {
                          // Dont include them
                      } else {
                          $html .= '<li><i>' . $field->getLabel() . ": " . $field->getValueAsString() . "</i></li>";
                      }
  
                  }
  
                  $html .= '</ul>';
  
                  $subject = "Enquiry received - [" . $form->getName() . "]";
  
                  $this->sendMail($html, $subject, $email);
              }
  
          }
      );
  
  ```
  
  And my function to send emails:
  
  ```
   private function sendMail($html, $subject, $mail = null): bool
  {
      $message = new Message();
  
      $message->setFrom(getenv('SYSTEM_EMAIL_ADDRESS'));
      $message->setTo($mail);
      $message->setSubject($subject);
      $message->setHtmlBody($html);
      
  
      return Craft::$app->mailer->send($message);
  }
  
  ```
  
  Hope this is useful for someone
  
  Happy coding :)
  
  
  ---
  
  