This applies to both scripts, FormToEmail and FormToEmail-Pro
With a standard installation the script will email the data from your form to one or more email addresses that are hard-coded into the script. You might want to give your visitor a choice of recipients to select from to send the form to. Typically you would offer these choices in a drop-down list with the visitor selecting one of them. The email containing the form data will be sent to the selected recipient.
You can offer this facility to your visitors by putting some HTML code in your form and adding some PHP code to the script.
Form code. To make a drop-down select in your form, copy the HTML code below and paste it into your form:
<select name="recipient">
<option value="">Choose a recipient</option>
<option value="recipient_1">Sales</option>
<option value="recipient_2">Support</option>
<option value="recipient_3">Customer service</option>
</select>
For the script to handle this input you need to add some PHP code to it. Open up the script in a text editor and locate this line, near the bottom:
mail($my_email,$subject,$message,$headers);
Above it, paste in this code:
$recipients = array(
'recipient_1' => 'sales@example.com',
'recipient_2' => 'support@example.com',
'recipient_3' => 'customerservices@example.com'
);
$my_email = $recipients[$_REQUEST['recipient']];
Note that the keys in the $recipients array correspond to the values in your form code. You can have as many options as you wish in the select list, just make sure that you have the corresponding email addresses in the $recipients array and that you follow the same naming convention above. Note, the last email address in the $recipients array does not have a comma after it.
That's all. Save the HTML file (webpage) that your form is on. Save the script then upload both files to your webspace.
When using this method you do not need to enter your email address(es) in the script in the standard way. If you do, it will be safely ignored and the email from the form will go to the selected recipient.
You will get the selected recipient showing up in the body of the email like "Recipient: recipient_1". If using the free script you will have to put up with this (for all it is). If you are using the Pro script you can ignore the recipient input by naming it in the fields to ignore configuration option. This simply means you will not see it in the body of the email but the email will still go to the correct recipient as selected from the list.