You can use data that contacts submit through Mautic forms directly in your emails or landing pages using Twig Templates.

Important: This only works if the email is sent using:

  • A “Send email to contact” action directly on a form.
  • A “Send email” action in a campaign that starts when a form is submitted.

Form Data Tokens

When an email is sent in one of the ways mentioned above, you can use these special tokens:

  • {{ formresult }}: Contains the data from the single, most recent form submission by the contact.
  • {{ formresults }}: Contains a list (array) of all form submissions made by the contact.

Using the Last Submission (formresult)

To show data from the contact’s latest form submission, use the formresult token. You access the submitted values using the form field’s alias (the unique name you gave the field).

<p>Thanks for submitting, {{ formresult.firstname }}!</p>
<p>Here's what we received:</p>
<ul>
  <li>First Name: {{ formresult.firstname }}</li>
  <li>Email: {{ formresult.email }}</li>
  {# Use the alias of your form field #}
  <li>Your Message: {{ formresult.message_field_alias }}</li>
</ul>

Using All Submissions (formresults)

If you need to show data from older submissions, you can loop through the formresults list. Each item in the list (result in the example below) works like the formresult token.

<p>Your submission history:</p>
<ul>
{% for result in formresults %}
    <li>
        Submitted on {{ result.dateSubmitted|date('Y-m-d H:i') }}:
        Name: {{ result.firstname }} {{ result.lastname }}
        {# Add other fields if needed #}
    </li>
{% else %}
    <li>You haven't submitted this form before.</li>
{% endfor %}
</ul>

This lets you show past interactions or use historical form data in your content.