ejoo
ejoo

Reputation: 61

Typo3 8.7: Different mail templates for form finisher EmailToReceiver / EmailToSender

I'm using the Typo3 form-module (sysext) with two email-finishers: EmailToReceiver vs. EmailToSender. I set up a custom mailtemplate, but

Upvotes: 3

Views: 3138

Answers (2)

sebkln
sebkln

Reputation: 1375

In addition to Mathias Brodala's correct answer, you can also use templateName and templateRootPaths inside each email finisher. It will respect the email format you set with options.format if configured like below:

finishers:
  -
    identifier: EmailToReceiver
    options:
      subject: 'E-Mail from website'
      recipientAddress: [email protected]
      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: [email protected]
      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

The complete tutorial can be found here.

On GitHub is a working TYPO3 extension with several example forms, including a form with custom mail template only for the sender.

Upvotes: 6

Mathias Brodala
Mathias Brodala

Reputation: 6460

You can use the templatePathAndFilename finisher option to set a custom template for your mails. You can set this for each finisher separately:

finishers:
  - identifier: EmailToReceiver
    options:
      # ...
      templatePathAndFilename: EXT:my_site/Resources/Private/Templates/.../EmailToReceiver.html

  - identifier: EmailToSender
    options:
      # ...
      templatePathAndFilename: EXT:my_site/Resources/Private/Templates/.../EmailToSender.html

Upvotes: 4

Related Questions