<p>Looks like you've got some nested escape tags in Twig, which is a no-no.</p>

<pre><code>value="{{ '{{category.contactEmail}}'|hash }}"
</code></pre>

<p>You just need to use:</p>

<pre><code>value="{{ category.contactEmail|hash }}"
</code></pre>

CC BY-SA 3.0
2016-06-30T21:34:12.610Z
2016-06-30T21:34:12.610Z
Brad Bell
<p>Link to Github repository for plugin: <a href="https://github.com/pixelandtonic/ContactForm" rel="nofollow">https://github.com/pixelandtonic/ContactForm</a></p>

<p>Being given an error by the plugin where it is interpreting my Twig variable literally as a string instead of what the variable is representing. I am looking for a way to fix this using the current set-up but having an alternate setup is fine as well. Also for reference, I have followed the guidelines on the README in regards to changing the craft/config/contactform.php file. Much appreciated for the help!</p>

<p>This is my code:</p>

<pre><code>{% macro errorList(errors) %}
{% if errors %}
    &lt;ul class="errors"&gt;
        {% for error in errors %}
            &lt;li&gt;&lt;span&gt;{{ error }}&lt;/span&gt;&lt;/li&gt;
        {% endfor %}
    &lt;/ul&gt;
{% endif %}
{% endmacro %}

{% from _self import errorList %}

&lt;div class="uk-width-large-1-2 uk-width-medium-1-2 uk-width-small-1-1 uk-container-center"&gt;
&lt;form method="post" action="" accept-charset="UTF-8"&gt;
    {{ getCsrfInput() }}
    &lt;input type="hidden" name="action" value="contactForm/sendMessage"&gt;

    &lt;ul id="button-content" class="uk-switcher uk-margin"&gt;
        &lt;li class="text-space basic-border"&gt;
            &lt;h3&gt;&lt;b&gt;Email to {{default.defaultcontactreason}}&lt;/b&gt;&lt;/h3&gt;
            &lt;input type="hidden" name="toEmail" value="{{ '{{default.defaultContactEmail}}'|hash }}"&gt;{{default.defaultContactEmail}}
        &lt;/li&gt;
    {% for category in craft.entries.section('Contacts') %}
        &lt;li class="text-space basic-border"&gt;
            &lt;h3&gt;&lt;b&gt;Email to {{ category.contactReason }}&lt;/b&gt;&lt;/h3&gt;
            &lt;input type="hidden" name="toEmail" value="{{ '{{category.contactEmail}}'|hash }}"&gt;{{category.contactEmail}}
        &lt;/li&gt;
    {% endfor %}
    &lt;/ul&gt;

    &lt;h3&gt;&lt;label for="fromName"&gt;Your Name&lt;/label&gt;&lt;/h3&gt;
    &lt;input id="fromName" type="text" name="fromName" value="{% if message is defined %}{{ message.fromName }}{% endif %}"&gt;
    {{ message is defined and message ? errorList(message.getErrors('fromName')) }}

    &lt;h3&gt;&lt;label for="fromEmail"&gt;Your Email&lt;/label&gt;&lt;/h3&gt;
    &lt;input id="fromEmail" type="text" name="fromEmail" value="{% if message is defined %}{{ message.fromEmail }}{% endif %}"&gt;
    {{ message is defined and message ? errorList(message.getErrors('fromEmail')) }}

    &lt;h3&gt;&lt;label for="subject"&gt;Subject&lt;/label&gt;&lt;/h3&gt;
    &lt;input id="subject" type="text" name="subject" value="{% if message is defined %}{{ message.subject }}{% endif %}"&gt;
    {{ message is defined and message ? errorList(message.getErrors('subject')) }}

    &lt;h3&gt;&lt;label for="message"&gt;Message&lt;/label&gt;&lt;/h3&gt;
    &lt;textarea rows="10" cols="40" id="message" name="message"&gt;{% if message is defined %}{{ message.message }}{% endif %}&lt;/textarea&gt;
    {{ message is defined and message ? errorList(message.getErrors('message')) }}

    &lt;input type="submit" value="Send"&gt;
    &lt;input type="hidden" name="redirect" value="{{siteUrl}}Contacts"&gt;
&lt;/form&gt;
&lt;/div&gt;
</code></pre>

CC BY-SA 3.0
2016-06-30T20:54:37.300Z
for reference, the exact exception reads: Invalid address: {{category.contactEmail}}
Matthew
<plugin-contactform>
phpmailer Exception while using Pixel & Tonic contact-form plugin
# phpmailer Exception while using Pixel & Tonic contact-form plugin

(Asked by: username_0 on 2016-06-30)

Link to Github repository for plugin: https://github.com/pixelandtonic/ContactForm
Being given an error by the plugin where it is interpreting my Twig variable literally as a string instead of what the variable is representing. I am looking for a way to fix this using the current set-up but having an alternate setup is fine as well. Also for reference, I have followed the guidelines on the README in regards to changing the craft/config/contactform.php file. Much appreciated for the help!
This is my code:
{% macro errorList(errors) %}
{% if errors %}
    
        {% for error in errors %}
            {{ error }}
        {% endfor %}
    
{% endif %}
{% endmacro %}

{% from _self import errorList %}



    {{ getCsrfInput() }}
    

    
        
            Email to {{default.defaultcontactreason}}
            {{default.defaultContactEmail}}
        
    {% for category in craft.entries.section('Contacts') %}
        
            Email to {{ category.contactReason }}
            {{category.contactEmail}}
        
    {% endfor %}
    

    Your Name
    
    {{ message is defined and message ? errorList(message.getErrors('fromName')) }}

    Your Email
    
    {{ message is defined and message ? errorList(message.getErrors('fromEmail')) }}

    Subject
    
    {{ message is defined and message ? errorList(message.getErrors('subject')) }}

    Message
    {% if message is defined %}{{ message.message }}{% endif %}
    {{ message is defined and message ? errorList(message.getErrors('message')) }}

**Tags:** plugin-contactform

> **Comments:**
> **username_0**: for reference, the exact exception reads: Invalid address: {{category.contactEmail}}  

---

## 1 answers

### Answer by username_1 on 2016-06-30. Score: 1 | Accepted answer

Looks like you've got some nested escape tags in Twig, which is a no-no.
value="{{ '{{category.contactEmail}}'|hash }}"

You just need to use:
value="{{ category.contactEmail|hash }}"


---

