Adding dynamic second email address to Contact Form plugin According to the Contact Form plugin docs, I can do:

&lt;input type="hidden" name="toEmail" value="{{ 'name@domain.com, name2@domain2.com' | hash }}"&gt;


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' %}
&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; #}


Any ideas?
Both, the example from the Contact Form docs

{{ '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.