mosparo Powermail

The mosparo Powermail extension extends the core mosparo Form integration by adapting the spam protection system specifically for use with Powermail forms. It provides seamless integration of mosparo’s validation and captcha functionality within Powermail’s form framework, enabling effective spam prevention while maintaining Powermail’s native features and workflows.

Introduction

Get an overview of the extension and its key features.

Installation

Explains how to install this extension in Composer-based and Classic TYPO3 installations.

Configuration

Learn how to use settings to configure this extension.

How to use

Learn how to integrate the mosparo field type into a Powermail form.

Frequently Asked Questions (FAQ)

These questions have been frequently asked.

How to get help

Learn where to get help and how to report issues you found.

Introduction

What does it do?

The mosparo Powermail extension extends the core mosparo Form integration by adapting the spam protection system specifically for use with Powermail forms. It provides seamless integration of mosparo’s validation and captcha functionality within Powermail’s form framework, enabling effective spam prevention while maintaining Powermail’s native features and workflows.

Features

This extension adds the following features:

  • A new form field type called "mosparo" that allows editors to easily add mosparo spam protection to forms
  • A mosparo validator that works together with the new form field type.
  • Ready-to-use JavaScript to properly load the captcha

Installation

Installation and configuration

  1. Install mosparo powermail with Composer or Install mosparo powermail in Classic Mode.
  2. Include static TypoScript via site set (TYPO3 v13 and above) or Include static TypoScript via TypoScript module.
  3. (Optional) Add additional project
  4. Start adding mosparo to your forms!

Install mosparo powermail with Composer

Install the extension via Composer:

composer req mahou/mosparo-powermail
Copied!

See also Installing extensions, TYPO3 Getting started.

Install mosparo powermail in Classic Mode

Or download the extension from https://extensions.typo3.org/extension/mosparo_powermail and install it in the Extension Manager.
The extension depends on the Extension mosparo_form.
Make sure this extension is installed in your TYPO3 environment or otherwise available so the extension can function properly.

Integrate mosparo Powermail into your TYPO3

Include static TypoScript via site set (TYPO3 v13 and above)

This extension comes with a site set called mahou/mosparo-powermail. To use it include this set in your site configuration via

config/sites/my-site/config.yaml (diff)
 base: 'https://example.com/'
 rootPageId: 1
+dependencies:
+  - denkwerk/mosparo-form
+  - mahou/mosparo-powermail
Copied!

See also: TYPO3 Explained, Using a site set as dependency in a site.

Include site set via Site Manager

It is also possible to include mosparo Form as site dependency directly in the backend:

  1. Got to module Site Management > Sites
  2. Edit your site configuration.
  3. In section Sets for this Site chose site set denkwerk/mosparo-form and mahou/mosparo-powermail.

Include static TypoScript via TypoScript module

This extension comes with static TypoScript that should be included if it has not been set in the site set.

  1. Go to section Includes > Include static (from extensions).
  2. In the Available Items list, first select "denkwerk – mosparo integration for EXT:form and Extbase-based forms", then "mosparo integration for EXT:powermail". Click each item to move it to the Selected Items.
  3. Now save your changes by clicking the Save button at the top.

Add additional project

mosparo enables you to define multiple independent projects, each with its own settings, rules, and style that can be used across multiple websites or forms. Before these projects can be selected by editors in TYPO3, they need to be configured.

Extending Field Type Lists in the FormNormalizer

This extension provides a FormNormalizer for the Powermail extension that helps with processing submitted form data. It allows specific field types to be ignored or verified during validation.

If you are using custom form field types, you need to register them via the event \Mahou\MosparoPowermail\Event\ModifyPowermailFormFieldTypeListsEvent to ensure proper validation behavior.

ModifyPowermailFormFieldTypeListsEvent

This event is triggered when the FormNormalizer is instantiated.

You can use this event to:

getIgnoredFieldTypes() / setIgnoredFieldTypes()

getIgnoredFieldTypes() / setIgnoredFieldTypes()
Type
array of strings

Add field types to the ignore list

getVerifiableFieldTypes() / setVerifiableFieldTypes()

getVerifiableFieldTypes() / setVerifiableFieldTypes()
Type
array of strings

Add field types to the verifiable list

Adding your own Event Listener

To register your own field types for the FormNormalizer, follow these steps:

  1. In your custom provider extension, create a new PHP file at: Classes/EventListener/ModifyFormFieldTypesForPowermailFormListener.php
  2. Add the following implementation.
    This example adds custom field types to both the ignored and verifiable lists:
    EXT:site_package/Classes/EventListener/ModifyFormFieldTypesForPowermailFormListener.php
    namespace Vendor\MyExtension\EventListener;
    
    use Mahou\MosparoPowermail\Event\ModifyPowermailFormFieldTypeListsEvent;
    
    final class ModifyFormFieldTypesForPowermailFormListener
    {
        public function __invoke(ModifyPowermailFormFieldTypeListsEvent $event): void
        {
            // Add custom field types to the ignore list
            $ignored = $event->getIgnoredFieldTypes();
            $ignored[] = 'customFormElementToIgnore';
            $event->setIgnoredFieldTypes($ignored);
    
            // Add custom field types to the verifiable list
            $verifiable = $event->getVerifiableFieldTypes();
            $verifiable[] = 'customFormInputElement';
            $event->setVerifiableFieldTypes($verifiable);
        }
    }
    Copied!
  3. Register the listener in your custom provider extension Services.yaml:

    EXT:site_package/Configuration/service.yaml
    ...
    
    services:
      Vendor\MyExtension\EventListener\ModifyFormFieldTypesForPowermailFormListener:
        tags:
          - name: event.listener
            event: Mahou\MosparoPowermail\Event\ModifyPowermailFormFieldTypeListsEvent
    Copied!

How to use

This section explains how to use the mosparo form field type a Powermail form.

  1. Create or edit a form.
  2. Add a new field and set its type to "mosparo".
  3. Set the title of the field to "mosparo"

    Powermail backend form field with the field type set to "mosparo"
  4. (Optional) Open the newly created field, switch to the Extended tab, and select the mosparo project you want to use for this form from the "Project" dropdown.

    "Mosparo Captcha" form field settings with the dropdown to select the mosparo projec

ModifyPowermailFormFieldTypeListsEvent

class ModifyPowermailFormFieldTypeListsEvent
Fully qualified name
\Mahou\MosparoPowermail\Event\ModifyPowermailFormFieldTypeListsEvent

This event allows extensions to modify which form field types should be ignored or considered verifiable by the Powermail Normalizer (\Mahou\MosparoPowermail\FormNormalizer\FormNormalizer).

__construct ( array $ignoredFieldTypes, array $verifiableFieldTypes)

Constructor.

param array<string> $ignoredFieldTypes

Initial list of field types to ignore.

param array<string> $verifiableFieldTypes

Initial list of field types to verify.

getIgnoredFieldTypes ( ) : array

Get the list of field types to be ignored by the FormNormalizer.

returntype

array<string>

setIgnoredFieldTypes ( array $types) : void

Set the list of field types to ignore.

param array<string> $types

New list of field types to ignore.

returntype

void

getVerifiableFieldTypes ( ) : array

Get the list of field types that should be verified by the FormNormalizer.

returntype

array<string>

setVerifiableFieldTypes ( array $types) : void

Set the list of field types that can be verified.

param array<string> $types

New list of field types to verify.

returntype

void

Frequently Asked Questions (FAQ)

See chapter Installation.

See chapter How to use.

Currently, mosparo validation only works in multi-step forms if all fields to be validated are located on the same step as the mosparo form field type. If the fields are spread across multiple steps, validation will not be triggered correctly.

This limitation is known and currently being worked on. See the related issue on GitHub:

See chapter Where to get help.