3

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

  • HOW can I select different mailtemplates for this two different mails?
  • OR is there another way to send two different mails?
ejoo
  • 51
  • 1
  • 7

2 Answers2

6

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: 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

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.

sebkln
  • 1,325
  • 1
  • 9
  • 17
4

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
Mathias Brodala
  • 5,905
  • 13
  • 30
  • Yes, I edited this value. So I set ONE template for both EmailToReceiver and EmailToSender. I need different tempates for this two cases. – ejoo Mar 09 '18 at 16:35
  • You can set the `templatePathAndFilename` inside each of the email finishers. This allows you to set different paths and use different mail templates. – sebkln Mar 09 '18 at 17:49
  • @mathias-brodala: But this way you are not able to make a difference between HTML and PLAINTEXT format, wright? – Stefan Padberg Mar 12 '18 at 11:48
  • You're already choosing the mail format with `options.format` inside the finisher configuration. Besides that, you can also set `templateRootPaths` as shown here: http://www.sklein-medien.de/en/tutorials/detail/different-e-mail-templates-for-emailtosender-and-emailtoreceiver-finishers-in-extform/ – `templateName: '{@format}.html'` will respect the format option, then. – sebkln Mar 12 '18 at 12:30
  • This is working fine, thanks. In addition: to change per form one could edit the files {formname}.yaml in fileadmin/user_upload/ (default path for conf-files made with the BE-form-editor). – ejoo Mar 14 '18 at 18:03
  • Getting error "The option "subject" must be set for the EmailFinisher. " could your please help me to fix – Geee Oct 18 '18 at 12:50
  • *Did* you set a subject? – Mathias Brodala Oct 18 '18 at 13:40