PHPackages                             boundstate/craft-contactform - PHPackages - PHPackages  [Skip to content](#main-content)[PHPackages](/)[Directory](/)[Categories](/categories)[Trending](/trending)[Leaderboard](/leaderboard)[Changelog](/changelog)[Analyze](/analyze)[Collections](/collections)[Log in](/login)[Sign up](/register)

1. [Directory](/)
2. /
3. [Utility &amp; Helpers](/categories/utility)
4. /
5. boundstate/craft-contactform

ActiveCraft-plugin[Utility &amp; Helpers](/categories/utility)

boundstate/craft-contactform
============================

Contact Form plugin for Craft

v1.9.0(9y ago)1151MITPHP

Since Aug 16Pushed 9y ago2 watchersCompare

[ Source](https://github.com/boundstate/craft-contactform)[ Packagist](https://packagist.org/packages/boundstate/craft-contactform)[ RSS](/packages/boundstate-craft-contactform/feed)WikiDiscussions master Synced today

READMEChangelog (2)Dependencies (2)Versions (3)Used By (0)

Contact Form plugin for Craft
=============================

[](#contact-form-plugin-for-craft)

This plugin allows you to add an email contact form to your website.

Installation
------------

[](#installation)

To install Contact Form, follow these steps:

1. Upload the contactform/ folder to your craft/plugins/ folder.
2. Go to Settings &gt; Plugins from your Craft control panel and enable the Contact Form plugin.
3. Click on “Contact Form” to go to the plugin’s settings page, and configure the plugin how you’d like.

Usage
-----

[](#usage)

Your contact form template can look something like this:

```
{% macro errorList(errors) %}
    {% if errors %}

            {% for error in errors %}
                {{ error }}
            {% endfor %}

    {% endif %}
{% endmacro %}

{% from _self import errorList %}

    {{ getCsrfInput() }}

    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')) }}

    {{ craft.contactform.getReCaptchaInput()|raw }}
    {{ message is defined and message ? errorList(message.getErrors('reCaptchaResponse')) }}

```

The only required fields are “fromEmail” and “message”. Everything else is optional.

### Redirecting after submit

[](#redirecting-after-submit)

If you have a ‘redirect’ hidden input, the user will get redirected to it upon successfully sending the email. The following variables can be used within the URL/path you set:

- `{fromName}`
- `{fromEmail}`
- `{subject}`

For example, if you wanted to redirect to a “contact/thanks” page and pass the sender’s name to it, you could set the input like this:

```

```

On your contact/thanks.html template, you can access that ‘from’ parameter using [craft.request.getQuery()](http://buildwithcraft.com/docs/templating/craft.request#getQuery):

```
Thanks for sending that in, {{ craft.request.getQuery('from') }}!
```

Note that if you don’t include a ‘redirect’ input, the current page will get reloaded.

### Adding additional fields

[](#adding-additional-fields)

You can add additional fields to your form by splitting your “message” field into multiple fields, using an array syntax for the input names:

```
Message
{% if message is defined %}{{ message.message }}{% endif %}

Your phone number

What services are you interested in?
 Design
 Development
 Strategy
 Marketing
```

If you have a primary “Message” field, you should name it `message[body]`, like in that example.

An email sent with the above form might result in the following message:

```
Phone: (555) 123-4567

Services: Design, Development

Hey guys, I really loved this simple contact form (I'm so tired of agencies
asking for everything but my social security number up front), so I trust
you guys know a thing or two about usability.

I run a small coffee shop and we want to start attracting more freelancer-
types to spend their days working from our shop (and sipping fine coffee!).
A clean new website with lots of social media integration would probably
help us out quite a bit there. Can you help us with that?

Hope to hear from you soon.

Cathy Chino

```

### Overriding plugin settings

[](#overriding-plugin-settings)

If you create a [config file](https://craftcms.com/docs/config-settings) in your `craft/config` folder called `contactform.php`, you can override the plugin’s settings in the control panel. Since that config file is fully [multi-environment](https://craftcms.com/docs/multi-environment-configs) aware, this is a handy way to have different settings across multiple environments.

Here’s what that config file might look like along with a list of all of the possible values you can override.

```
