Send TYPO3 EXT:powermail mail to different receivers depending on selection in a dropdown

只谈情不闲聊 提交于 2019-12-03 20:21:38
randomresult

With the help of @alex-kellner in the slackchannel of EXT:powermail i found a quite easy solution for that:

Basically there are 2 Steps needed:

Step1

Values for the Options in the select field. You need to add values to your option in the select field. This can be done by appending a pipe | to your option and simply add the value

MyRecieverEmail 1 | 1

MyRecieverEmail 2 | 2

MyRecieverEmail 3 | 3

In addition to that, you need to know the marker / variable / individual fieldname of your field. You can find that name in the extended tab of your field.

You can also give this field an "own" variable name if needed. The variable is wrapped with {} but you will not these in step 2

Step 2

Now you need to add some TS in your setupfield.

Background information: Basically this changes the reciever for a form:

plugin.tx_powermail.settings.setup.receiver.overwrite.email = TEXT
plugin.tx_powermail.settings.setup.receiver.overwrite.email.value = your@email.com

Now you need to check wich option was choosen in the form. This is done by a global condition:

[globalString = GP:tx_powermail_pi1|field|yourVariableFieldname = 1]

Where yourVariableFieldname ist the individual fieldname from the extended tab in the field and 1 is the value of the first option (MyRecieverEmail 1)

By using this TS, the form will be send to your@email.com if the first option MyRecieverEmail 1 is choosen in the form:

[globalString = GP:tx_powermail_pi1|field|yourVariableFieldname = 1]
plugin.tx_powermail.settings.setup.receiver.overwrite.email = TEXT
plugin.tx_powermail.settings.setup.receiver.overwrite.email.value = your@email.com
[global]

You can now add as much conditions as you need. The complete example would be:

[globalString = GP:tx_powermail_pi1|field|yourVariableFieldname = 1]
plugin.tx_powermail.settings.setup.receiver.overwrite.email = TEXT
plugin.tx_powermail.settings.setup.receiver.overwrite.email.value = yourfirst@email.com
[global]
[globalString = GP:tx_powermail_pi1|field|yourVariableFieldname = 2]
plugin.tx_powermail.settings.setup.receiver.overwrite.email = TEXT
plugin.tx_powermail.settings.setup.receiver.overwrite.email.value = yoursecond@email.com
[global]
[globalString = GP:tx_powermail_pi1|field|yourVariableFieldname = 3]
plugin.tx_powermail.settings.setup.receiver.overwrite.email = TEXT
plugin.tx_powermail.settings.setup.receiver.overwrite.email.value = yourthird@email.com
[global]

Please be aware that this will be in charge for every field with the fieldname {yourVariableFieldname} in your TYPO3-Install where this TS is taken into account. This can be useful if you use this field exactly like this in multiple forms. If you dont want this to be in charge you have 2 options to avoid this:

  1. only place the TS on the Page where your form is located.

  2. You can add this to your global condition:

    && [globalString = GP:tx_powermail_pi1|mail|form = 123]

Where 123 is the ID of your form.

This would then look like this:

[globalString = GP:tx_powermail_pi1|field|yourVariableFieldname = 2] && [globalString = GP:tx_powermail_pi1|mail|form = 123]
标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!