1 min read

Statamic Email Form Plugin

This is a plugin for Statamic that is designed to allow you to quickly and easily create email forms. Currently it is pretty basic but flexible so it should be a great starting point. I hope to get feedback on this release and then make improvements over time.

Installation

Copy the “email” folder to your _add-ons directory.

Example Form Template

Here is a full example to get you going. Please see the parameters section
for more field options:

{{ noparse }}{{ email:form subject="Contact Form" to="eric@ericlbarnes.com" required="name" }}
    {{ if error}}
        <h1>Error</h1>
        <ul>
        {{ errors }}
            <li>{{error}}</li>
        {{ /errors }}
        </ul>
    {{ endif }}

    {{ if success }}
        <h1>IT WORKED!</h1>
    {{ else }}
        <p>
            <label for="name">Name:</label>
            <input type="text" name="name" id="name" value="Bill">
        </p>
        <p>
            <label for="from">Email:</label>
            <input type="text" name="from" id="from" value="test@test.com">
        </p>
        <p><input type="submit"></p>
    {{ endif }}
{{ /email:form }}{{ /noparse }}

Parameters

The {{ noparse }}{{ email:form }}{{ /noparse }} tag accepts the following paramaters:

  • subject: The subject of the email.
  • to: The form recipient’s email address.
  • cc: A cc email address.
  • bcc: A bcc email address.
  • required: A pipe seperated list of required fields. Example: “name|address|city”. Currently this only does simple validation to check if it is an empty value.

Issues / Gotchas

The name field is hard coded as the reply name in the plugin so it is recommended you use this field in your form.

Contribute

Keep in mind this is the first release so if you see any issues or have ideas for improvements pull requests are gladly
accepted. 😉

Download

You can clone the repo by running the code below:

$ git clone git@github.com:ericbarnes/Statamic-email-form.git

Or visit the GitHub Repo.