Forum

Thread tagged as: Forms

Sending form contents to different recipients based on field selection in a form

I have a simple contact form on a site. The client is requesting that the site visitor be able to choose the subject of their inquiry via a dropdown, and for the email to then go to a specific email address based on which subject is selected. So if a visitor filling out the form picks, "I need help with XYZ" the email gets sent to him@site.com, but if the question is "I'd like to return XYZ" the email gets sent to her@site.com.

Is that possible with the Form app?

Thanks!

Franz Neumann

Franz Neumann 0 points

  • 6 years ago
Drew McLellan

Drew McLellan 2638 points
Perch Support

Not with the Forms app, no.

Ok, thanks.

I got asked the same by a customer the other day, using the Form App. We solved it using the enquiry subject dropdown that you're using. All emails are being sent to the same address. The customer is setting up local filtering to search for the different preset subjects in the email body - and then auto-redirect the message to another email account within the organisation.

Simon Clay

Simon Clay 127 points

I've not tested this, but is it not possible to have the value in the options as the email addresses?

Like this:

<perch:content id="subject" type="select" label="Subject" 
options="I need help with xyz|him@site.com, I'd like to return xyz|her@site.com" allowempty="false" required="true" />

and then in Form Options add {subject} as the email recipient.

I think the recipient would see their email address as the subject however.

I just tried Simon's suggestion and it seems to work perfectly.
I even added a repeater to give the client the possibility to add subjects—or names in my case—and e-mail addresses.

<perch:label for="recipient">To</perch:label>
<perch:input type="select" id="recipient" label="Recipient" options="
    <perch:repeater id="recipients" label="Recipients">
        <perch:content id="name" type="text" label="name" />|<perch:content id="email" type="text" label="e-mail" /><perch:if id="perch_item_index" match="neq" value="{perch_item_count}">,</perch:if>
    </perch:repeater>
" />

Then in Form Options I added {recipient} as the email address.

The <perch:if> part prevents an empty item at the end of the options, btw.