View Full Version : Multiple Recipients - Drop Down Menu
trippo
20-Jun-2007, 10:37 PM
I have designed a form to work as a missed telephone call register, where my staff can open the page, select who missed the call from dropdown list (emails and values are stored in the page code) fill out details and hit send.
Instead of the script sending all emails to the recipient defined in the page or formmail.php, can I work the script so it sends the email to the person who is selected in the drop down list?
If not, where do I look for a easy script that will allow me to do this.
Best regards
Trippo
russellr
21-Jun-2007, 01:46 AM
Hi,
Yes. Set TARGET_EMAIL in FormMail to match all your company email addresses (check the documentation for more information on this setting).
Then, the drop down field simply sets the "email" field (ie. the "select" has "name=email").
WebGerl
06-Aug-2008, 05:44 PM
I thought I'd post under this thread rather than make a new one. I looked in the documentation and it doesn't really help me.
I tested this type of form with drop menu recipients. There are about 9 recipients. The target email in the formmail has all of the company email addresses. Now, how do I force the form to send to only one of the recipients rather than sending the email to all of the recipients at once?
What do I put in recipients of the hidden input field? All of the company email addresses or one? On the drop down menu field, how do I implement company email addresses properly? I used option name to put in the email address (eg: <option name="email">).
ginger23
06-Aug-2008, 07:43 PM
Hi,
You want to name the dropdown field "recipients". Then create an INI file and put all of the "names" of the recipients in there spelled exactly as you have them in the dropdown, with their associated email address.
Here's an example of an INI file:
http://www.tectite.com/fmhowto/inifile.php
Check out the way they did the [email_addresses] section. You'll need one of those for each person in your dropdown list.
However, you won't use a hidden field for recipients at all when using the dropdown.
The $TARGET_EMAIL setting is there for you to specify which email addresses are ALLOWED to receive emails from the form. This is a security feature. The recipients field is how you specify who you want the results mailed to.
When the form is submitted with someone's name from the dropdown selected, the script will read the ini file and see what email address goes with the name that was selected.
This also keeps the email addresses out of the form and away from spambots.
Hope that helps,
ginger
WebGerl
06-Aug-2008, 11:18 PM
Thanks so much for the reply. I did what you suggested. The error I got is:
"The following error occurred in FormMail :
no_valid_recipients
**********
Error=The form has an internal error - no valid recipients were specified."
Here's the html form code I used:
<form method="post" action="http://www.xyz.com/fmp.php" name=" Contact Form">
<input type="hidden" name="env_report" value="REMOTE_HOST,REMOTE_ADDR,HTTP_USER_AGENT,AUTH_TYPE,REMOTE_USER">
<!-- STEP 2: Put your email address in the 'recipients' value.
Note that you also have to allow this email address in the $TARGET_EMAIL setting within formmail.php! -->
<!-- STEP 3: Specify required fields in the 'required' value --><input type="hidden" name="required" value="realname:Your name,comments" />
<!-- STEP 4: Put your subject line in the 'subject' value. --><input type="hidden" name="subject" value="Contact Form" />
<input type="hidden" name="good_url" value="http://www.xyz.com./thanks.html">
<input type="hidden" name="bad_url" value="http://www.xyz.com/failed.html">
<select name="recipients" id="dept">
<option name="rec1" value="rec1" selected="selected">Information</option>
<option name="rec2" value="rec2">Chairperson</option>
<option name="rec3" value="rec3">Volunteer</option>
<option name="rec7" value="rec7">Advertising</option>
<option name="rec5" value="rec5">Entertainment</option>
<option name="rec6" value="rec6">Refreshment</option>
<option name="rec9" value="rec9">Admission</option>
<option name="rec4" value="rec4">Exhibit</option>
<option name="rec8" value="rec8">Webmaster</option>
</select>Here's the formmail.ini that I used:
[email_addresses]
rec1 = info@xyz.com
rec2 = chair@xyz.com
rec3 = volunteer@xyz.com
rec4 = exhibit@xyz.com
rec5 = entertainment@xyz.com
rec6 = refreshment@xyz.com
rec7 = interpreter@xyz.com
rec8 = webmaster@xyz.com
rec9 = admission@xyz.com
I'm not sure what I'm missing here.
ginger23
07-Aug-2008, 01:39 AM
A couple of things I noticed are:
1. Your options shouldn't have names, just values. (Athough this is improper HTML it's probably not the cause of your error, although it could be.)
2. You don't have quotation marks around your email addresses in formmail.ini. Should be:
rec1 = "info@xyz.com"
Did you specify the server path to formmail.ini in the script? I think the setting is called: $FORM_INI_FILE . Note, this file should either be stored outside of your root directory or protected with .htaccess so spambots can't see it. I have mine above the root. (Note, you can use http://yourdomain.com/formmail.php?testalert=1 to get a test email that will show you the server path to your document root, which is helpful for specifying the path to a file above the root.)
Hope that helps.
ginger
WebGerl
07-Aug-2008, 10:50 PM
Ok, I did remove the option names from the drop down menu form and just used values. Then I double checked the formmail.ini to add the quotation marks to the email addresses. Then I double checked the root path directory for storing ini which is outside of the directory where the formmail script is. I still receive same error: no_valid_recipients. How do I resolve this once again?
ginger23
08-Aug-2008, 01:24 AM
It's hard to say without seeing all the paths and code. It sounds like maybe the script isn't finding the INI file. Can you post what you have for the $FORM_INI_FILE setting? You didn't remove the name "recipients" from the <select name="recipients"> tag did you?
WebGerl
08-Aug-2008, 04:02 PM
It's hard to say without seeing all the paths and code. It sounds like maybe the script isn't finding the INI file. Can you post what you have for the $FORM_INI_FILE setting? You didn't remove the name "recipients" from the <select name="recipients"> tag did you?
No, I didn't remove <select name=recipients"> tag. Second, I don't know if it makes all of the difference but the website is hosted on a Windows server so the root path isn't typical Linux structure. It uses D:/ path. That's what I put down for $form_ini_file using D:/ path. I had modified the formmail to execute on Windows server which worked just fine till I try to make this kind of form.
ginger23
09-Aug-2008, 05:41 PM
Check the setting for $TARGET_EMAIL and make sure that you have accurate information there.
The only other thing could be the path. You might want to check with your host about the path.
Something you can try is just testing the form with one address in $TARGET_EMAIL, and selecting that address/recipient from the dropdown list. It seems that sometimes people have trouble when specifying multiple addresses in $TARGET_EMAIL.
If that works, then you know that the problem is with how you're specifying multiple addresses in $TARGET_EMAIL.
ginger
Powered by vBulletin® Version 4.1.4 Copyright © 2012 vBulletin Solutions, Inc. All rights reserved.