Multiple Recipients (Yes read the readme, this is different)

We just began using your scrip on our site because our old one wasn't secure. However, with our old script, the user could choose from a drop-down list of recipients to send the e-mail to. (Sales, service, etc.) Could your script handle this as well, or is that a bad idea from a security standpoint?

-Mike

P.S. Thanks for replying to my other post, it worked! :)

Comment viewing options

Select your preferred way to display the comments and click "Save settings" to activate your changes.

Multiple Recipients (Yes read the readme, this is different)

You can do it and still be secure.

You'll want to define the $recipient_array with keys and values. The keys have to be unique and the values will be the recipients e-mail address.

$recipient_array = array('joe'=>'joe@example.com', 'sally'=>'sally@example.com');

Then in the form you'll want to do a drop down or whatever. Make the unique key the value for your input.

-Andrew Riley

Multiple Recipients (Yes read the readme, this is different)

This is how our form code looked before:

Sales
Service

I am not sure how to change it to match your script.

-Mike

Multiple Recipients (Yes read the readme, this is different)

Ok I still have no clue how to make it work doing a drop-down, so I am trying to make it work using checkboxes, but I am getting an error

Here is my form code:

Sales
Service

Here is my PHP code:

$recipient_array = array(key1=>'sales@mydomain.com','key2'=>'service@mydomain.com');

Here is the error:

Quote:
There is no recipient to send this mail to. Please read the manual section titled "Form Configuration - Recipient".

Multiple Recipients (Yes read the readme, this is different)

in my form code above it is ...value="key2">Service

I had a typo

Multiple Recipients (Yes read the readme, this is different)

Nevermind, I figured it out.

:)

-Mike

Multiple Recipients (Yes read the readme, this is different)

Ok, I thought I had it, but both recipients get the e-mail no matter which checkbox is selected. I want to be able to send to only sales or only service or both simultaneously.

-Mike

Multiple Recipients (Yes read the readme, this is different)

Using the code from Andrew's example:

$recipient_array = array('joe'=>'joe@example.com', 'sally'=>'sally@example.com');

your dropdown code should read:

Joe Schmoe
Sally Sallyslastname

This is what he meant by being secure, you can still only send to the values in the recipient_array and as a bonus you don't reveal joe's or sally's email addresses to spam bots.

How would you implement

How would you implement something like this on a form.
I am using a drop down list that has Support, Sales, Billing.

Thank you!

I'm trying to implement this

I'm trying to implement this as well. I have populated my recipient array and I've created a form. In the form there is a dropdown menu from which the user selects which person they would like to contact. How do I make the email go to the person they select, and not to the other person in the recipients?

Example:

(< & > replaced with [ & ] so that the code would show)

[input type="hidden" name="recipient" value="email1, email2"]

[select name="company" id="company"]
[option value="Please select one:"]Please select one:[/option]
[option value="email1"]Contact Person A[/option]
[option value="email 2" selected]Contact Person B[/option]

[/select]

From the php file:

$recipient_array = array('email1' => 'PersonA@domain.com','email2' => 'PersonB@domain.com');

Any help would be greatly appreciated!

You just need to change the

You just need to change the name of your select to "recipient".

[select name="recipient" id="company"]
[option value="Please select one:"]Please select one:[/option]
[option value="email1"]Contact Person A[/option]
[option value="email2" selected]Contact Person B[/option]
[/select]

Thank you so much, it looks

Thank you so much, it looks like that did the trick!

User login