Email Form

Introduction

Create simple and easily emails from within your templates. Define your own fields, and use the dynamically created variables inside the email template tag.

Nothing fancy in the control panel (expect saving the submissions), just simple building your email, with template inside your template file.

Installation

Prerequisites

Make sure your system meets the minimum requirements:

Installation Instructions

  1. Upload ee2/system/third_party/email_form to system/expressionengine/third_party/
  2. Install the module in Add-Ons → Modules

Updating

  1. Create a backup of your Database
  2. Run the EE update process

License field

This module is using a license field to check if the license for the module is valid or not. On addons.reinos.nl you can check your license and add your valid domains.

Control panel overview

In the Module CP you can enter then your license Control panel overview

When you enter a wrong license, the module will not work and it shows you an warning Control panel overview

On a local environment, like *.dev *.local *.localhost *.test the license will be valid for the testing and building new sites.

How it works

The idea of the email form is that you have total freedom of the form markup and how to send the email in an easy way.

First you create a <form> inside the {exp:email_form:form} tag. Also you can set an email template with the syntax {email_template} inside the template tag {exp:email_form:form}. As in some situation you only want to send an email template to the admin or to the admin and the user, but differ in text style. With the {email_template} you can create it. So it is normal to end up with 2{email_template} tags.

When a user submit a form, the data that is posted via the form are transferred on the background to the {email_template} tagpair. So if you have a field with the name name="address", the value of address would be converted to the var {address} inside the tagpair {email_template}. Some values are special, like the {to:name}. As you set the to:name="" param on the {email_template to:name="John Doe"} this param will be converted to an variable {to:name} inside the {email_template}.

Control Panel

Settings

Here you can save the common settings

Submissions

Submissions are saved by default. Here you can manage and explorer them.

Forms

The forms you add in your code can also be saved in the control panel.

Encryption Key

The Email Form use the Encryption class provided by CodeIgniter. In order to work with the Email Form you have to setup a key for the Encryption class first.T

To do that you have to add a config for encryption_key in your config file (ExpressionEngine docs

Example

$config['encryption_key'] = 'sy22k6QK6JzH38u4nLZ65bHOdK6VL89d';

Tag

{exp:email_form:form}

Tag Parameters

Below are the Tag Parameters. Those parameters can be used in the tag described above

return_url

Specify the url to return after submission

return_url="/submission/success"

error_return_url

Specify the url to return on error

error_return_url="/form/error"

required_fields

Set the required field for the form

required_fields="field_1|field|2|field_3"

form_class

Set the class of the form

form_class="submission-form"

form_id

Set the ID for the form

form_id="submission-form"

secure

Disable/enable the secure function for the forms.

secure="no"

name

If you add a form in the backend, you can select this one here

name=""

email_form_allowed_types

Select the types of files that are allowed to upload.

email_form_allowed_types="gif|jpg|png"

Tag Variable

Below are the Tag Variables. Those Variables can be used in the tag described above

email_template

Inside this tagpair you can build your own template, instead of using the default templates defined inside the control panel.

More information here

{email_template}
  This email is sent to {to:name} with the following message: <br />
{body}
{/email_template}

success

The succes message

{success}

validation_errors

Show all validation errors

[EE2]
{validation_errors}

[EE3]
{validation_errors}
    {field} - {error}<br>
{validation_errors}

attachments_error

Show the attachment errors

{attachments_error}

debug

Show the debug message

{debug}

Get Form tag

{exp:email_form:get_form name=''}

Tag Parameters

Below are the Tag Parameters. Those parameters can be used in the tag described above

name

The name of the form

name=""

Custom variables

The email_form module whas build because of the use of dynamic variables inside the template which is declared inside your template file and inside the {exp:email_form:form} tag.

Those variables are simply defined by declaring form fields. See the example page for a real use case.

Email template

The email_template is used inside the form tag. This page describe the parama's.

{email_template} ... {/email_template}

Tag Parameters

Below are the Tag Parameters. Those parameters can be used in the tag described above

mailtype

Set the mailtype for sending the email.
Options: html text

mailtype="text"

to

Set the receipient email

to="example@example.com"

from:email

Set the From email

from:email="from@example.com"

from:name

Set the From name

from:name="John Doe"

cc

cc receipients, Multiple values seperated by a pipline (|)

cc="test@example.com|test2@example.com"

bcc

bcc receipients, Multiple values seperated by a pipline (|)

bcc="test@example.com|test2@example.com"

subject

Subject for the email

subject="New email"

attachments

Include attachments by field name (pipline seperated for multiple files)

attachments="myfile|myfile_2"

name

To identify the template in the hooks

name="email_template_1"

Hooks

email_form_send_start

This hook is called right before sending the email. With this hook you can modify the data. (e.g. for in Postmaster)

Added in 1.0

if (ee()->extensions->active_hook('email_form_send_start') === TRUE)
{
    $email_data = ee()->extensions->call('email_form_send_start', $email_data);
}

email_form_send_end

This hook is called right after sending the email.

Added in 1.0

if (ee()->extensions->active_hook('email_form_send_end') === TRUE)
{
    ee()->extensions->call('email_form_send_end', '');
}

email_form_form_start

Added in 1.2

if (ee()->extensions->active_hook('email_form_form_start') === TRUE)
{
    ee()->extensions->call('email_form_form_start', '');
}

email_form_form_end

Added in 1.2

if (ee()->extensions->active_hook('email_form_form_end') === TRUE)
{
    $return = ee()->extensions->call('email_form_form_end', $return);
}

email_form_attachment

assign extra files via an extension. Make sure you return an array with filenames

Added in 1.8

if (ee()->extensions->active_hook('email_form_attachment') === TRUE)
{
    ee()->extensions->call('email_form_attachment', $extra_fields, $vars);
}

Changelog

3.1.1 (08-06-2018)

3.1.0 (25-04-2018)

*Note: you need to add your license key and license email from addons.reinos.nl in order to validate your license and add a valid domain url in your license field on addons.reinos.nl/profile/licenses or the module will not work on a live site. Also make sure you have read the license section in the documentation

3.0.0 (04-12-2017)

2.0.4 (01-11-2017)

2.0.3 (01-05-2017)

2.0.1 (21-06-2016)

2.0.0 (20-06-2016)

1.8.1

1.8

1.7

1.6.1

1.6

1.5.4

1.5.3

1.5.2

1.5.1

1.5

1.4.1

1.4

1.3

1.2.1

1.2

1.1

1.0