BeforeEmailFinisherInitializedEvent 

New in version 14.0

The PSR-14 event BeforeEmailFinisherInitializedEvent has been introduced to provide developers with control over email configuration without needing to extend or override the EmailFinisher class.

A PSR-14 event \TYPO3\CMS\Form\Event\BeforeEmailFinisherInitializedEvent is dispatched before the \TYPO3\CMS\Form\Domain\Finishers\EmailFinisher is initialized and allows listeners to modify the finisher options.

This enables developers to customize email behavior programmatically, such as:

  • Setting alternative recipients based on frontend user permissions
  • Modifying the email subject or content dynamically
  • Replacing recipients with developer email addresses in test environments
  • Adding or removing CC/BCC recipients conditionally
  • Customizing reply-to addresses

Example: Change the recipients and subject of the email finisher 

The corresponding event listener class:

EXT:my_extension/Classes/Form/EventListener/MyEventListener.php
<?php

declare(strict_types=1);

namespace MyVendor\MyExtension\Form\EventListener;

use TYPO3\CMS\Core\Attribute\AsEventListener;
use TYPO3\CMS\Form\Event\BeforeEmailFinisherInitializedEvent;

final readonly class BeforeEmailFinisherInitializedEventListener
{
  #[AsEventListener(
    identifier: 'my-package/form/modify-email-finisher-options',
  )]
  public function __invoke(BeforeEmailFinisherInitializedEvent $event): void
  {
    $options = $event->getOptions();
    $context = $event->getFinisherContext();

    // Overwrite recipients based on FormContext
    if ($context->getFormRuntime()->getFormDefinition()->getIdentifier() === 'my-form-123') {
      $options['recipients'] = ['user@example.org' => 'John Doe'];
    }

    // Modify subject dynamically
    $options['subject'] = 'Custom subject: ' . ($options['subject'] ?? '');

    // Clear CC and BCC recipients
    $options['replyToRecipients'] = [];
    $options['blindCarbonCopyRecipients'] = [];

    $event->setOptions($options);
  }
}
Copied!

API 

final class BeforeEmailFinisherInitializedEvent
Fully qualified name
\TYPO3\CMS\Form\Event\BeforeEmailFinisherInitializedEvent

Listeners are able to modify the options, used by the EmailFinisher. Possible use cases might be unsetting recipients or to changing the subject of the mail.

getFinisherContext()
Returns
\TYPO3\CMS\Form\Domain\Finishers\FinisherContext
getOptions()
Returns
array<string,mixed>
setOptions(array<string, mixed> $options)
param $options

the options