Hello.
I noticed a few people have been wanting to make a contact form where it was possible to have the message directed to different mail accounts depending on user selection. A somewhat decent solution has been suggested here: http://blog.qzminski.com/2010/03/cre...-with-the-efg/ but this made use of EFG´s confirmation mail system to deliver the actual message, rendering it impossible to use the confirmation system for what it was intended.
The following solution is possible without EFG (Extended Form Generator http://www.contao.org/extension-list...130009.en.html) although you need it if you want to use confirmation mails.
Step 1:
Set up a contact form in form generator, with fields for message and users email. The link above to blog.qzminski.com describes this process quite well.
In addition we need a field with multiple values for the various different email addresses we want the message to be forwarded to. This should be a select menu.
Step 2:
Install extensions Formrecipient http://www.contao.org/extension-list...000009.en.html and ProtectedSelect http://www.contao.org/extension-list...000009.en.html
Formrecipient enables us to use insertTags in our backend form fields, which links to a form input value in the frontend input field, i.e. our newly created select/dropdown box.
ProtectedSelect enables us to hide values of the select box, so the different email addresses are not exposed in the frontend.
Step 3:
In the form generator, proceed to edit the select menu you created. Under options you can add as many fields/values as you wish, each have 3 fields: Reference, Value and Label.
Reference works to connect the hidden email address with what is visible as value in the frontend. You can enter what you wish but it must be unique for each field.
Value is the email address you want to use.
Label is the title of the specific select option that the user sees in the front end.
So a setup could be like this: Reference: servicesref // Value: service@domain.com // Label: Our services.
So when a user selects Our services Contao will use the email of service@domain.com to send the message to.
Under "Field type and Name" section choose an appropriate "Field label", which will show up in the frontend, and a unique "field name" which we will use in the next step. Avoid using "subject" as field name, as this will make the email address into the subject of the message. In this example we choose a field name of "regarding"
Finally make sure that the "Field type" is now "Protected Select menu"
Step 4:
In the form generator proceed to edit the form itself.
- Under "Send form data" enable "Send form data via email".
- Choose "E-mail" as "data format".
- Enable "skip empty fields"
- Choose a "subject", i.e. "Web contact"
and now for the clever thing. Under "Recipient address" insert the following including curly braces: {{form::regarding}}
This way the recipient address will be whatever option the user chooses in the select box.
Hope this works for you, otherwise let me know.
Regards,
Jesper Mathiasen, Aveor gmbh, Hamburg.
Bookmarks