Forum

Thread tagged as: Question, Forms

Is there any way to change the form email recipient based on a form value?

I have a contact form with a dropdown for selecting the type of enquiry. This is running through the Forms app. It currently emails the response to a fixed email address.

However, ideally I would like to be able to direct the response email to the appropriate person based on this enquiry type. Is this possible?

Chris George

Chris George 0 points

  • 3 years ago
Simon Clay

Simon Clay 127 points

Hi, yes it is.

In the Form Options, in the 'Sent to Email address' field you can add the ID of the field you want to pull the value from.

Eg. if you have a form that contains a select list with the enquiry types, the 'value' can be the email you'd like it to go to...

<perch:input type="select" id="enquiry_type" options="General|general-enquiries@me.com,Complaints|customer-services@me.com,Technical|support@me.com" label="Enquiry Type" />

Then in your Form Options you can put the ID for that field surrounded by curly braces {enquiry_type} and it'll use the value.

Drew McLellan

Drew McLellan 2638 points
Perch Support

I would advise against doing this as it will open you up as a spam relay.

Simon Clay

Simon Clay 127 points

Ah, because we're showing our full email address in the frontend code right?

In that case, what I have done in my instance is this: As the value, just add the first part of the email address (assuming it's always the same domain)...

<perch:input type="select" id="enquiry_type" options="General|general-enquiries,Complaints|customer-services,Technical|support" label="Enquiry Type" />

Then in your Form Options you can put the ID for that field surrounded by curly braces followed by the @domain {enquiry_type}@me.com.

ah cool that works thanks! Ok, slight variation now....

So I would like to put the text of the enquiry type in the subject, and use the value of the enquiry type as the email address. It feels like I need to use some sort of conditional variable?

Good point Drew, and Simon, I like the workaround. My second question still stands (I wrote it before your other replies and sent it afterwards!). (All but one option will be sent to one email address, and one sent to a different one)

Drew McLellan

Drew McLellan 2638 points
Perch Support

The subject of the email is set in the Forms app UI, so you can't make that conditional. You can substitute variables, but not perform conditions.

You can use conditional logic in the email template, however.

Ok. Can I affect the target email address through the email template?

for example, I have 3 enquiry type options general enquiry|info@somewhere.com specific enquiry|info@somewhere.com booking enquiry|booking@somewhere.com

I would like "general enquiry" to be in the subject of the email, while being sent to the email address. As far as I can see, I can do conditional logic in the email template on the enquirytype value, but this will be the same in two of the cases, therefore cannot distinguish between them.

I've had a look through various example templates, and none of them set the target email address so I'm assuming this is done purely via the forms settings page.

thanks for your help

Chris

Drew McLellan

Drew McLellan 2638 points
Perch Support

No, you can't change the email address from the template.