I often have the requirement to send a powermail-form to different receivers depending on a selection of a selectfield within the form. Im using TYPO3 7.6.x and Powermail 3.3.0 How can this be done?
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:
only place the TS on the Page where your form is located.
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]