1

I am building a site that lists different service providers.

On each service provider's page there is a contact form (the same form for each service provider).

The email address of each service provider (the recipient) is in the channel entry.

How can I get the email sent to each respective service provider - as well as the site owner?

I am trying to avoid using a different script for each form - and I don't want to expose the recipient's email address in the page code.

1

If you look at the Template Parsing order, you will see that segment variables are parsed before Preload Replace Variables. You can take advantage of that.

{if segment_2 == "foo"}
    {preload_replace:pr-recipient="contact@foo.com,"}
{if:elseif segment_2 == "bar"}
    {preload_replace:pr-recipient="sales@bar.com,"}
{/if}

    {preload_replace:pr-recipient=""}

{exp:email:contact_form user_recipients="no" recipients="{pr-recipient}site-owner@example.com" charset="utf-8"}

    [...]

{/exp:email:contact_form}
| improve this answer | |
1

I'm not exactly sure how the above answer would have worked, I'm really not sure I understood it. :/

However, I was able to accomplish what I wanted pretty easily with Solspace's Freeform. Also I needed custom fields which Freeform is great at doing.

Also I need to mention Solspace has awesome support.

| improve this answer | |

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.