首页 > 解决方案 > Typo3:编辑表单插件使用的电子邮件模板

问题描述

目前我正在使用 Typo3 中的基本表单插件制作联系表单。我把它全部设置好了,它工作正常并且符合预期。我唯一的问题是我收到的电子邮件看起来很糟糕。我的表单有 10 个不同的输入,它只是返回某种列表中的字段。

输出如下所示:

male
Test     
123  
test@test,de
1

虽然它应该看起来像这样:

Gender: male
Name: Test   
Age: 123     
E-Mail: test@test,de
Agreed to TOS: yes

我试图用谷歌搜索这个问题的解决方案,因为我认为为此创建一个模板并不难,但到目前为止我还没有找到任何对我有用的东西。

我在这里尝试过这个解决方案并阅读了提供的 github 示例,但我不知道如何将解决方案应用到我的项目中。我已将此代码实现到我的.yaml文件中:

templateName: 'template.html'
  templateRootPath:
    20: 'EXT:extension/Resources/Private/Forms/Templates/'

但是,一旦我尝试提交表单,我就会收到一堆错误。我也不知道在模板文件本身中写什么,我试图复制github 中提供的内容,但不知何故我的代码甚至找不到我的模板文件。

有谁知道这个问题的解决方案?

标签: formstypo3typo3-extensions

解决方案


在 YAML 中,缩进用于表示嵌套(配置的结构)。因此,您需要确保每个设置都正确缩进。

templateName并且templateRootPaths都是 EXT:form 中电子邮件整理器的相同选项:

finishers:
  -
    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
      # The following part enables us to use the customized template:
      templateName: '{@format}.html'
      templateRootPaths:
        20: 'EXT:form_examples/Resources/Private/Forms/CustomHtmlMailExample/Sender/'

正如您自己已经弄清楚的那样,表单标签将呈现在 TYPO3 表单框架的默认电子邮件模板中。如果在表单定义中设置了标签,则标签和表单值将呈现在一个简单的 HTML 表中。


推荐阅读