Answers.Body: <p>This is how to achieve this :</p>
  
  <pre><code>&lt;?php
  
  return array(
      'toEmail' =&gt; ('firstemail@domain.com,secondemail@domain.com' ?: null),
  );
  </code></pre>
  
Answers.ContentLicense: CC BY-SA 3.0
Answers.CreationDate: 2016-06-09T09:34:37.153Z
Answers.Text: Well done Romain! - Please add the template tag to your answer, too
Answers.UserDisplayName: Matt P
Answers.ContentLicense: CC BY-SA 3.0
Answers.CreationDate: 2016-06-09T09:43:38.340Z
Answers.Text: Thanks! There is no template tag related to recipients because they are dynamically set from the contactform.php config file.
Answers.UserDisplayName: Romain P.
Answers.ContentLicense: CC BY-SA 3.0
Answers.CreationDate: 2016-06-09T09:58:19.183Z
Answers.Text: Got it. Apologies, I misunderstood.
Answers.UserDisplayName: Matt P
Answers.ContentLicense: CC BY-SA 3.0
Answers.CreationDate: 2016-06-09T09:15:08.887Z
Answers.LastActivityDate: 2016-06-09T10:42:32.973Z
Answers.LastEditDate: 2016-06-09T10:42:32.973Z
Answers.UserDisplayName: Romain P.
Body: <p>I don't want to show up the email recipients in the source code using this :</p>
  
  <pre><code>&lt;input type="hidden" name="toEmail" value="{{ 'me@example.com,me2@example.com'|hash }}"&gt;
  </code></pre>
  
  <p>I want to manage multiple emails dynamically from the contactform.php config file in my craft/config folder. </p>
  
  <pre><code>&lt;?php
  
  return array(
      'toEmail' =&gt; (hash('firstemail@domain.com, secondemail@domain.com') ?: null),
  );
  </code></pre>
  
  <p>This config file is not working and don't override the plugin settings in the CP. What would be the best way to achieve this ?</p>
  
  <p><strong>[UPDATE]</strong></p>
  
  <p>I ended to this, but while it is working fine in the front end, this is causing PHP errors in the CP :</p>
  
  <pre><code>&lt;?php
  
  return array(
      'toEmail'  =&gt; array(
          ('firstemail@domain.com' ?: null),
          ('secondemail@domain.com' ?: null)
       )
  );
  </code></pre>
  
Tags: <plugin-development><plugin-contactform>
Title: P&T Contact Form plugin : how can I dynamically add multiple email recipients inside the form config file?
ThreadText: # P&T Contact Form plugin : how can I dynamically add multiple email recipients inside the form config file?
  
  (Asked by: username_0 on 2016-06-09)
  
  I don't want to show up the email recipients in the source code using this :
  
  ```
  <input type="hidden" name="toEmail" value="{{ 'me@example.com,me2@example.com'|hash }}">
  
  ```
  
  I want to manage multiple emails dynamically from the contactform.php config file in my craft/config folder.
  
  ```
  <?php
  
  return array(
      'toEmail' => (hash('firstemail@domain.com, secondemail@domain.com') ?: null),
  );
  
  ```
  
  This config file is not working and don't override the plugin settings in the CP. What would be the best way to achieve this ?
  
  **[UPDATE]**
  
  I ended to this, but while it is working fine in the front end, this is causing PHP errors in the CP :
  
  ```
  <?php
  
  return array(
      'toEmail'  => array(
          ('firstemail@domain.com' ?: null),
          ('secondemail@domain.com' ?: null)
       )
  );
  
  ```
  
  **Tags:** plugin-development, plugin-contactform
  
  
  ---
  
  ## 1 answers
  
  ### Answer by username_0 on 2016-06-09. Score: 1 | Accepted answer
  
  This is how to achieve this :
  
  ```
  <?php
  
  return array(
      'toEmail' => ('firstemail@domain.com,secondemail@domain.com' ?: null),
  );
  
  ```
  
  > **Comments:**
  > **username_1**: Well done username_0! - Please add the template tag to your answer, too  
  > **username_0**: Thanks! There is no template tag related to recipients because they are dynamically set from the contactform.php config file.  
  > **username_1**: Got it. Apologies, I misunderstood.  
  
  ---
  
  