Illustration: Form sends two different email templates

Different e-mail templates for EmailToSender and EmailToReceiver finishers in EXT:form

It is quite simple to assign individual templates for the sent emails, using the Form Framework of TYPO3 v8.

As the new Form Framework in TYPO3 v8 is used by more and more integrators, one question is asked frequently: how can I configure different email templates for sender and receiver, when there is only one Fluid template for both email finishers?

While this is basically true – EXT:form per default uses the same HTML and plaintext templates for both finishers – there's an easy way to assign different templates for the EmailToSender and EmailToReceiver finishers.

The trick is that you can set own templateRootPaths to the desired email template in each finisher. The following example is an excerpt from a form definition – a YAML file containing the form which was created with EXT:form. It only shows the definition of the two finishers. The renderables (form fields) and the rest of the definition were left out. Further below you'll find a complete example.

Form definition (finisher excerpt)

finishers:
  -
    identifier: EmailToReceiver
    options:
      subject: 'E-Mail from website'
      recipientAddress: your.company@example.com
      recipientName: 'Your Company name'
      senderAddress: '{email}'
      senderName: '{lastname}'
      replyToAddress: ''
      carbonCopyAddress: ''
      blindCarbonCopyAddress: ''
      format: html
      attachUploads: 'true'
      templateName: '{@format}.html'
      templateRootPaths:
        20: 'EXT:your_extension/Resources/Private/Forms/Emails/Receiver/'
      translation:
        language: ''
  -
    identifier: EmailToSender
    options:
      subject: 'Your message'
      recipientAddress: '{email}'
      recipientName: '{lastname}'
      senderAddress: your.company@example.com
      senderName: 'Your Company name'
      replyToAddress: ''
      carbonCopyAddress: ''
      blindCarbonCopyAddress: ''
      format: html
      attachUploads: 'true'
      templateName: '{@format}.html'
      templateRootPaths:
        20: 'EXT:your_extension/Resources/Private/Forms/Emails/Sender/'

According to the file paths set above, the templates are then saved in

  • your_extension/Resources/Private/Forms/Emails/Sender/
    Html.html or Plaintext.html
  • your_extension/Resources/Private/Forms/Emails/Receiver/
    Html.html or Plaintext.html

Need a complete and working example?

If you want to know more about building forms with EXT:form, there's a dedicated example extension on GitHub. Among other forms, it includes a customized HTML email template which gets sent only to the sender of the form. Just install the extension and embed a form on your page, it works out-of-the-box.

Happy form building!

Example extension on GitHub

Back