Name

_email

Type

_email

Synopsis

Using a form to send an email

Description

FlexForm can send a submitted form as an email. The FlexForm tag needs an action of 'email' for this. All other setting are done through the _email function.

An email is send using an email template. Such an email template can be any page in the Wiki where you define the details for the email.

When sending an email you need certain information:

At form level means this can be set within the Form. At template level means this is set within the template.
Name Type At form level At template level Mandetory
To email address yes yes yes
From email address no yes yes
Subject text yes yes yes
Content text no yes yes
CC email address no yes no
BCC email address no yes no
Reply to email address no yes no
Attachment Filepath no yes no
Header Wiki Page no yes no
Footer Wiki no yes no

Mail addresses can be also be formatted. It can be person@company.com, but you can also use Mr. Person [person@company.com]. The email will then be addressed to Mr. Person.


All the elements needed to send an email can be set inside the email template. You can create multiple email templates. You simply tell FlexForm what email template to use in the form. The elements that can be set at form level will override any defined elements in the template.

All form elements that should be send with the email, must be defined in the email template. If you have an input element of type text and a name of "address" and you want to send this with the email, you have to put the name of the field inside the template with a "$"-sign in front of it( in this case $address). See examples.

Form Parameters

to = recipients email address

template = Title name of Wiki pages containing the email template

subject = Subject of the email to be send

Template Parameters

_to = recipients email address

_from = senders email address

_subject = email subject

_cc = email address that receives a copy of the email

_bcc = email address that receives a copy of the email, but not visible to anyone else

_reply-to = email address used when someone replies to the send email

_header = Title name of Wiki page with the email letterhead

_footer = Title name of Wiki page with the email footer

_html = Value can be yes or no, defaults to yes. Whether or not the email should be send as HTML (yes) or plain text (no)

_attachment = full url to the file that needs to be attached. If you want to use a file from the wiki, use "file:< name of the file>" without any namespaces.


If everything is defined in an email template, then _email would only need the template argument to send an email.

Example

<form action="email">
 <_email template="FlexForm_mail_template"></_email>
 <input type="text" name="name" placeholder="Your name" />
 <input type="email" name="email" placeholder="Your email address" />
 <input type="text" name="city"  placeholder="City you live" />
 <input type="submit" value="submit your information" />
</form>

Wiki page with title "FlexForm_mail_template"

%_to=$email%
%_bcc=info@wikibase.nl%
%_subject=Form submitted from website by $name%
%_from=info@wikibase.nl%

<p>Dear <strong>$name</strong>,</p>
<p>
  Thank you for submitting the form on our website. We have received the following details:</p>
  <ul>
    <li>Name : $name</li>
    <li>Email : $email</li>
    <li>City : $city</li>
</ul>
<p>We will contact you shortly</p>
<p>Best regards</p>

Parsing

FlexForm will first parse the email template and then substitute form names in the email template with the form values. If you want to have this reversed, use the parselast argument on the _email function.

Note / Tip

Since the email template is parsed, you can fill the value for e.g. the _bcc email addresses with a Semantic Media Parse function. Effectively you could create a newsletter function with this feature. Additionally.. when u use the Api function FlexFormBot you can create a Python function or a Maintenance script that could be triggered using a Cron job to send newsletters automatically.

Links

The above Tip, basically creating a newsletter, is explained in more detail in this Developer log : https://wikibase-solutions.com/developer-logs/create-a-newsletter-with-flexform