Login / Status
developer.Resource
Home . Documentation . Document Library . Extension Manuals
Sponsors
hosted by punkt.deTYPO3 and Open Source Magazine

1.5. Configuration and usage of mailformplus

  • Install the module with the Extension manager.

  • Insert a “plugin” element on the page where the form should be shown – pluginname: “mailformplus”.

  • Insert a new “mailformplus” element on the page: (make sure you only have one mailformplus element per page!) best practice: switch to “list” view and click on “create new record” on the very bottom of the page.

  • configure the mailformplus element Tipp: since version 3.5.0 you can define default values for the fields via TypoScript! see section “General TypoScript” for more information.

the HTML form: subtemplates for emails and errormessages

You can (have to) specify a “HTML-Template with formular fields in it”.

This is a “normal” static HTML document including the formular fields.

Make sure you don't have a <BODY> or <HTML> tag in there – it should only contsists of the real pure HTML-form starting with <form .... > and ending with </form>

You can also declare javascript functions if you like to check some fields before the form is submitted.

NEW in version 2.0: “templating within the HTML-form”:

You can define texts for

  • the formular itself (as in version 1.0)

  • a “thank you” text that is shown when you did not specifiy a “redirect to” link after submitting the form

  • template for the email-text the user gets sent when he submitted the form (only if specified)

There are some hidden fields you have to declare in the HTML-form have a look at this example here:

Example: (with javascript check, fileupload, error messages):

<!-- ###TEMPLATE_FORM### begin
  shows formular field to be filled out
-->
<script language="JavaScript" type="text/JavaScript">
<!--
function chkFormular() {
  if (document.Formular.surename.value == "") {
  alert("Please insert your surename!");
document.Formular.surename.focus();
return false;
   }
   return true;
 }
//-->
</script>
<form name="Formular" onSubmit="return chkFormular()" method="post" action="index.php" enctype="multipart/form-data">
<input type="hidden" name="id" value="###PID###">
<input type="hidden" name="submitted" value="1">
<input type="hidden" name="L" value="0">
###ERROR###
Surename:<br />
###error_surename###
<input type=”text” name=”surename” value=”###value_surename###”>
<br />
email:<br />
###error_email###
<input type=”text” name=”email” value=”###value_email###”>
<br />
Topic: <br/>
###error_topic###
<select name="topic" style="width:320px;">
<option value="empty" ###selected_topic_empty###></option>
<option value="webdesign" ###selected_topic_webdesign###>Webdesign</option>
<option value="feedback" ###selected_topic_feedback###>Feedback</option>
</select>
<br />
Contact: <br />
<input type="radio" name="contact_via" value="email" style="border-style:none;" ###checked_contact_via_email###>e-mail 
<input type="radio" name="contact_via" value="phone" style="border-style:none;" ###checked_contact_via_phone###>Phone
<br />
Photo(s):<br />
###error_filesize######error_filetype###
<input type="file" name="photo" size="50" maxlength="50000" accept="image"><br>
<input type="file" name="photo2" size="50" maxlength="50000" accept="image">
<br />
<input type=”submit” value=”submit”>
</form>
<!-- ###TEMPLATE_FORM### end -->
<!-- ###TEMPLATE_SUBMITTED_OK### begin
  OPTIONAL - will be shown if form was submitted and all required fields were filled out
-->
<b>Thank you, your request will be answered soon.</b>
<!-- ###TEMPLATE_SUBMITTED_OK### end -->
<!-- ###TEMPLATE_EMAIL_USER### begin
    OPTIONAL - this will be the email text that is sent to the user (plaintext!)
-->
Hello ###surename###,
You have just submitted our form:
Your name: ###surename###
your email: ###email###
you want to be contacted via: ###contact_via###
you uploaded the following files:
###photo###
###photo2###
ciao! 
<!-- ###TEMPLATE_EMAIL_USER### end -->
<!-- ###TEMPLATE_EMAIL_RECEIVER### begin
    OPTIONAL - this will be the email text that is sent to the admin (plaintext!)
    (admin-email = the email you can specify in the mailformplus plugin)
-->
Hello admin,
A user just filled out our form:
name: ###surename###
email: ###email###
please contact the user via: ###contact_via###
the user has uploaded the following files:
###photo###
###photo2###
<!-- ###TEMPLATE_EMAIL_RECEIVER### end -->
<!-- ###TEMPLATE_ERROR### begin
  OPTIONAL – this section holds the error texts for the input fields.
Only a primitive server side check is supported: you can specify fiels that have to be filled out. If not, this error message is shown.
-->
<!-- ###ERROR_START### begin 
this is used for the global error marker ###ERROR### -->
The following errors occured:
<ul>
<!-- ###ERROR_START### end -->
<!-- ###ERROR_END### begin 
this is used for the global error marker ###ERROR### -->
</ul>
<!-- ###ERROR_END### end -->
<!-- ###ERROR_FILESIZE### begin 
this is used if you use the file upload functionality -->
<li>File is too large!</li>
<!-- ###ERROR_FILESIZE### end -->
<!-- ###ERROR_FILETYPE### begin 
this is used if you use the file upload functionality -->
<li>File is not allowed!</li>
<!-- ###ERROR_FILETYPE### end -->
<!-- ###ERROR_email### begin -->
<li>insert email</li>
<!-- ###ERROR_titel### end -->
<!-- ###TEMPLATE_ERROR### end -->

Default emails:

If no Template ###TEMPLATE_EMAIL_RECEIVER###  or ###TEMPLATE_EMAIL_USER### is defined,  all fields will be sent to the specified emailaddress in this format:

[fieldname]: [value]

 

Special fields:

###value_surename###

abstract: ###value_[name of inputfield]###

If the form was submitted but not filled out correct, this placeholder fills out the inputfield with the data the user has submitted. (otherwise the inputfield would be empty again)

###checked_contact_via###

abstract: ###checked_[name of checkbox/radiobutton]_[value of checkbox/radiobutton]###

If the form was submitted but not filled out correct, this placeholder selects the correct checkboxes/radiobuttons the user has filled out before. (otherwise the checkbox/radiobutton would be not checked again)

###selected_contact_via###

abstract: ###selected_[name of pulldown]_[value of pulldown]###

If the form was submitted but not filled out correct, this placeholder selects the correct entry in a pulldown-field the user has filled out before. (otherwise the first entry would be selected)

###[dynamic typoscript field]###

abstract: ###[marker name from typoscript]###:

if you have defined a marker like:

plugin.tx_thmailformplus_pi1.markers.departments < temp.departments

the placeholder “departments” in the HTML-template will be replaced with the rendered TypoScript code.

###ERROR###

abstract: ###ERROR###

This displays all error messages cumulated. Useful if you want to want the error messages to appear all at the beginning of the form.

###error_surename###

abstract: ###error_[fieldname]###

This displays the error message for the field. Currently this is only displayed if you have defined the field as “have to” field in the backend and the user has not filled it out. Useful if you want to display a error message directly next to the field and not at the beginning of the form cumulated like it is done with ###ERROR###.

###FEUSER_NAME###

abstract: ###FEUSER_[fieldname]###

You can access name, email, ... fields from the logged in user (frontend-user) and fill out the name or emailaddress automatically. (new in 2.4.0)

Attention: the fieldname has to be written in CAPITAL letters

###CAPTCHA###

Only works if you have the “captcha” extension installed. This marker will be replaced with a picture showing some only human readable text. The user has to type the text shown on the picture into a inputfield in your form. To enable the check if the submitted text is the same as shown on the picture, you have to set the following TypoScript

plugin.tx_thmailformplus_pi1.captchaFieldname = [name of the inputfield]

See section “general Typoscript” for more information.

uploaded files:

The markers of uploaded files are automatically prefixed with the domain and the path where the file is uploaded to.

Example: if you add the ###photo### placeholder in the admin or user email, the user will find a link to the uploaded file in the mail.

Example:

http://www.mydomain.com/uploads/mailform_photos/12_photo_234.jpg

For a detailed description about the uploaded filename please read the section “Saving the submitted values into a DB table of your choice (TS)”

FAQ

Q: Can i specify mulitple emailaddresses where the formular should be sent to?

A: yes: just write a “,” seperated list of the recipients in the “send formular to this email” field.

Q: Can i use mailformplus for mulitple formular fields on one page?

A: This is not tested – that might depend on how you have the different formulars defined. If two formulars have the same name this won't work. Just give it a try and let me know :)

Q: I have added a fileupload button, but the file is not sent along with the email to the admin ?

A: File upload is currently only supported if you save the submitted fields into a DB table of your own choice.

Known problems

  • on some servers the domain of the sender emailaddress has to be hosted on the server otherwise no email is sent. (see FAQs)