Contact form that goes to different recipients based on selection

I use Contact Form 7, the most popular and versatile way to add a contact form to your site. If you’re not the only person involved, though, you might want to have the email go to different destinations depending on a selection on the form. For instance:

screenshot of contact form showing "what is this regarding" selection field

When a visitor submits the form, the Contact Form 7 plugin sends the information by email. But depending what someone chooses in this dropdown field, you’ll want to direct the email to whoever who deals with that area.

To do this, define the field with selections of the form “text of selection|email address” — there’s a vertical bar character between the two parts. So the definition of the form would include something like this:

<label> What is this regarding?
   [select* recipient include_blank
      "Website problem|webmaster@yourdomain.com"
      "Volunteering|mabel@gmail.com"
      "Press inquiry|pr@yourdomain.com"
      "Other|kate@yahoo.com"
   ]
</label>

NOTE: line breaks and indentation for clarity; this would work the same if it were all on one line.

The above code creates the selection field and establishes who is responsible for each area. I’ve chosen to name the field “recipient” (that’s in the above text also). To arrange for that selection to drive who receives the email, use the Mail tab of the contact form editing screen, and enter that field name in square brackets in the To field.screenshot of Mail tab og contact form editor

That’s it! You should be set to go.

Share...

Leave a Reply

Your email address will not be published. Required fields are marked *