Answers.Body: <p>Both, the example from the <a href="https://github.com/pixelandtonic/ContactForm" rel="nofollow">Contact Form docs</a></p>
  
  <pre><code>{{ 'me@example.com,me2@example.com'|hash }}
  </code></pre>
  
  <p>...and the 3rd example snippet in your question</p>
  
  <pre><code>{% set firstEmail = 'me@example.com' %}
  {% set emails = firstEmail ~ ',me2@example.com' %}
  
  {{ emails|hash }}
  </code></pre>
  
  <p>...output exactly the same string for me! So I think you have to search for an answer to your issue elsewhere.</p>
  
Answers.ContentLicense: CC BY-SA 3.0
Answers.CreationDate: 2016-06-30T11:58:44.927Z
Answers.Text: FWIW this syntax should also work `(firstEmail ~ ',me2@example.com')|hash`, first cancat and then apply the filter.
Answers.UserDisplayName: carlcs
Answers.ContentLicense: CC BY-SA 3.0
Answers.CreationDate: 2016-06-30T11:55:42.957Z
Answers.LastActivityDate: 2016-06-30T11:55:42.957Z
Answers.UserDisplayName: carlcs
Body: <p>According to the Contact Form plugin docs, I can do:</p>
  
  <pre><code>&lt;input type="hidden" name="toEmail" value="{{ 'name@domain.com, name2@domain2.com' | hash }}"&gt;
  </code></pre>
  
  <p>That seems to work fine, but one of those email addresses I want to add dynamically. I've tried the following, but none seem to work, generally sending to just the second email address:</p>
  
  <pre><code>{# adding first email as var #}
  {% set firstEmail = 'name@domain.com' %}
  &lt;input type="hidden" name="toEmail" value="{{ firstEmail ~ ', name2@domain2.com' | hash }}"&gt;%}
  
  {# adding first email as var and avoiding | hash #}
  {% set firstEmail = 'name@domain.com' %}
  &lt;input type="hidden" name="toEmail" value="{{ firstEmail ~ ', name2@domain2.com' }}"&gt;%}
  
  {% set firstEmail = 'name@domain.com' %}
  {% set emails = firstEmail ~ ', name2@domain2.com' %}
  &lt;input type="hidden" name="toEmail" value="{{ emails | hash }}"&gt;
  {# RESULT: &lt;input type="hidden" name="toEmail" value="505103f2971d445c709c131b8eee0a59e3ff668bname@domain.com, name2@domain2.com"&gt;#}
  
  {# adding first email as var with extra quotes #}
  {% set firstEmail = 'name@domain.com' %}
  {% set emails = "'" ~ firstEmail ~ ", name2@domain2.com'" %}
  &lt;input type="hidden" name="toEmail" value="{{ emails | hash }}"&gt;
  {# RESULT: &lt;input type="hidden" name="toEmail" value="e3a44b3632212521351d8d44af34742a63f6516e'name@domain.com, name2@domain2.com'"&gt; #}
  </code></pre>
  
  <p>Any ideas?</p>
  
Comments.ContentLicense: CC BY-SA 3.0
Comments.CreationDate: 2016-06-30T08:32:07.193Z
Comments.Text: Missing the quotes around the email addresses?
Comments.UserDisplayName: carlcs
Comments.ContentLicense: CC BY-SA 3.0
Comments.CreationDate: 2016-06-30T09:02:40.493Z
Comments.Text: Sorry, I've put those back in. I've added a fourth example as well.
Comments.UserDisplayName: Clive Portman
Comments.ContentLicense: CC BY-SA 3.0
Comments.CreationDate: 2016-06-30T09:45:48.897Z
Comments.Text: Hmm.. your 3rd example should actually work now.
Comments.UserDisplayName: carlcs
Comments.ContentLicense: CC BY-SA 3.0
Comments.CreationDate: 2016-06-30T11:29:26.603Z
Comments.Text: That's what I thought. I've added the output of that third example.
Comments.UserDisplayName: Clive Portman
Tags: <plugin-contactform>
Title: Adding dynamic second email address to Contact Form plugin
ThreadText: # Adding dynamic second email address to Contact Form plugin
  
  (Asked by: username_0 on 2016-06-30)
  
  According to the Contact Form plugin docs, I can do:
  
  ```
  <input type="hidden" name="toEmail" value="{{ 'name@domain.com, name2@domain2.com' | hash }}">
  
  ```
  
  That seems to work fine, but one of those email addresses I want to add dynamically. I've tried the following, but none seem to work, generally sending to just the second email address:
  
  ```
  {# adding first email as var #}
  {% set firstEmail = 'name@domain.com' %}
  <input type="hidden" name="toEmail" value="{{ firstEmail ~ ', name2@domain2.com' | hash }}">%}
  
  {# adding first email as var and avoiding | hash #}
  {% set firstEmail = 'name@domain.com' %}
  <input type="hidden" name="toEmail" value="{{ firstEmail ~ ', name2@domain2.com' }}">%}
  
  {% set firstEmail = 'name@domain.com' %}
  {% set emails = firstEmail ~ ', name2@domain2.com' %}
  <input type="hidden" name="toEmail" value="{{ emails | hash }}">
  {# RESULT: <input type="hidden" name="toEmail" value="505103f2971d445c709c131b8eee0a59e3ff668bname@domain.com, name2@domain2.com">#}
  
  {# adding first email as var with extra quotes #}
  {% set firstEmail = 'name@domain.com' %}
  {% set emails = "'" ~ firstEmail ~ ", name2@domain2.com'" %}
  <input type="hidden" name="toEmail" value="{{ emails | hash }}">
  {# RESULT: <input type="hidden" name="toEmail" value="e3a44b3632212521351d8d44af34742a63f6516e'name@domain.com, name2@domain2.com'"> #}
  
  ```
  
  Any ideas?
  
  **Tags:** plugin-contactform
  
  > **Comments:**
  > **username_1**: Missing the quotes around the email addresses?  
  > **username_0**: Sorry, I've put those back in. I've added a fourth example as well.  
  > **username_1**: Hmm.. your 3rd example should actually work now.  
  > **username_0**: That's what I thought. I've added the output of that third example.  
  
  ---
  
  ## 1 answers
  
  ### Answer by username_1 on 2016-06-30. Score: 1
  
  Both, the example from the [Contact Form docs](https://github.com/pixelandtonic/ContactForm)
  
  ```
  {{ 'me@example.com,me2@example.com'|hash }}
  
  ```
  
  ...and the 3rd example snippet in your question
  
  ```
  {% set firstEmail = 'me@example.com' %}
  {% set emails = firstEmail ~ ',me2@example.com' %}
  
  {{ emails|hash }}
  
  ```
  
  ...output exactly the same string for me! So I think you have to search for an answer to your issue elsewhere.
  
  > **Comments:**
  > **username_1**: FWIW this syntax should also work `(firstEmail ~ ',me2@example.com')|hash`, first cancat and then apply the filter.  
  
  ---
  
  