Search code examples
concrete5

concrete5 Form - Change recipient email based on a drop down menu


When you create a form in concrete5, you have the ability to specify a Recipient Email in Edit Mode.

Is it possible to send the email to a certain address based on a drop down menu selection?

Any help/resources on this are appreciated.

Thanks in advance, Mike


Solution

  • No. Not out of the box. And I can't think of a good, easy solution within concrete5, either. You can look at the add-ons in the marketplace (there is at least one advanced form block for sale).

    You could also, maybe, send to everyone (via commas, or a distribution address) and let the recipients figure it out.

    If you're going to build your own solution, it's pretty straightforward:

    1. Create a new field ("question") in the form.
    2. Copy the controller to your /blocks/form directory (as per tutorials on extending concrete5).
    3. Edit the PHP code right before it sends the email to check if a question by the name you've specified has been posted. If so, check that*, and send to that address instead of the default.

    *Important -- don't just trust what the form posts... do a basic check (like making sure it's at your domain, or a hardcoded whitelist. Otherwise some script will figure out that it can "hack" the form and add an arbitrary address, and you'll become an unwitting spammer.