4

We need to send to three email addresses when a particular select option is selected. I've tried setting the value of that field (called recipient_email) to foo@bar.com,baz@bar.com and setting recipients=yes and recipient_limit=3 on the form, but the form just comes through to the default admin notification email.

Any suggestions? This in on EE 2.6.1 and Freeform 4.0.12.

Here's a cut down version of the template code:

{exp:freeform:form 
collection="General Contact Form"
return="{embed:return}/category/submitted" 
form:id="form-general-contact" 
form:class="validate no-print" 
required="first_name|surname|email|recipient_email|user_message"
recipients="yes" 
recipient_limit="3"
}

<fieldset>

    <div class="fr">
        <label for="sel-general-type">Enquiry Type <span class="required">*</span></label>
        <div class="wrapper-select">
            <select id="sel-general-type" name="recipient_email">
                <option value="foo@bar.com,baz@bar.com">Foo</option>
                <option value="bar@foo.com">Bar</option>
            </select>
        </div>
    </div>
6

The recipient_email field accepts encoded recipient email values (see an example here), using the {freeform:recipient_value} variable in the field's name="" attribute along with a set list of recipients using recipient1="", recipient2="", etc parameters.

If you want your field's value="" to be an regular, non-encoded email address (as you have it above), use recipient_email_user field (documentation).

To send to multiple recipients, use name="recipient_email[]" or name="recipient_email_user[]" for your field. Please note the brackets [].

You cannot have more than one email address as a field's value="".

In your case, however, you are using a select field, which cannot accept multiple values. Either change the field to checkboxes or a multi-select field, eg.

<input type="checkbox" name="recipient_email_user[]" value="email1@example.com" /> Recipient 1<br />
<input type="checkbox" name="recipient_email_user[]" value="email2@example.com" /> Recipient 2<br />
<input type="checkbox" name="recipient_email_user[]" value="email3@example.com" /> Recipient 3<br />

...or use javascript/jQuery to populate hidden recipient_email_user[] fields when a select field option is selected.

| 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.