On 5/2/05 balam responded:
Easily done!
In your webpage form, you would need to put this:
<select name="recipient" size="1">
<option>Select recipient</option>
<option value="1">ME</option>
<option value="2">YOU</option>
<option value="3">HIM</option>
<option value="4">HER</option>
</select>
In FormMail.pl, you would need to put this:
%recipient_alias = (
'1' => 'me@example.com',
'2' => 'you@example.com',
'3' => 'him@example.com',
'4' => 'her@example.com'
);
I have finally gotten around to do this and I am running into a problem. When I submit the form, it is being sent to the default email account on the hosting account, not the specific email address that is selected from the dropdown menu. Here is the pertinent code from my formmail.pl script:
@referers = qw(mydomain.com);
@allow_mail_to = qw();
@recipients = (mail.mydomain.com);
%recipient_alias = (
'1' =>'jan@mydomain.com', '2'=>'bob@mydomain.com');
Here is the code from the form on the Web page:
<select name="Recipient" size="1">
<option value="1">Jan, MIS</option>
<option value="2">Bob, Marketing</option>
</select>
Any help would be greatly appreciated.
Thanks
I noticed one definite problem and one potential problem with the code you posted.
Definate problem:
@recipients = (mail.mydomain.com);
Change the above to:
@recipients = ();
Potential problem:
<select name="Recipient" size="1">
Change the above to:
<select name="recipient" size="1">
I say that's a potential problem - the uppercase 'R' - but I'm not sure if it's definately a problem. Doesn't hurt to make "recipient" all lowercase!
Let us/me know if the problem's solved...
I tried your suggestions and they didn't work :(
But I do think I figured out what the problem is. On the Web page form, I have the following:
<input type="hidden" name="recipient" value="info" /> The
value="info" was from the previous use of the script for sending emails to a single recipient. But how would I change it now to handle the multiple recipients?
Keep/make the changes I mentioned above, and completely delete the (old) hidden <input>.
What is happening here is that your drop-down box is setting "recipient=1" (if you select the first recipient), while the hidden input is setting "recipient=info". The end result is the script doesn't know just who-to/where the message is supposed to go - since you're feeding it conflicting info - and it's probably sending you a "500 Server Error" at the moment.
Delete & report back here! :)
I am now receiving the following error msg for Formmail:
There was no recipient or an invalid recipient specified in the data sent to FormMail. Please make sure you have filled in the recipient form field with an e-mail address that has been configured in @recipients or @allow_mail_to. More information on filling in recipient/allow_mail_to form fields and variables can be found in the README file.The recipient was: [ 1 ]
Before removing the <input> line, the email was being sent - no 500 error - but to the default email address not the one specified in FormMail.
What next?
I ponder your predicament while playing GTA, then I sleep on it. ;)
Ok, the program obviously works - to some extent, at least. Are you using the latest version? (It's 3.14 - you'll find the version number at the top of the program. If you need to upgrade, highly recommended, visit The nms Project [nms-cgi.sourceforge.net].)
At this point, I can't help but think that the problem is something that is silly & small, like a misplaced apostrophe in "%recipient_alias". Double-check your HTML and the configuration section of FormMail.pl for any obvious errors.
More in the morrow...
I am testing this for a client who will be installing it on their own server, which I currently don't have access to. So in order to test it, I installed their files on my site with their own sub-directory. I had been correctly identifying all the paths correctly for their files except for the formmail.pl file. I forgot to change the path to their version of the formmail file from the Web page form. So instead of retrieveing their formmail script, it was accessing my formmail script. Doh!
It is working like a charm right now. Thanks for your time and help on this. I really appreciate it.
gldweb
Excellent, great news! Like I said, I was being to think it was something small, overlooked.
There's one last issue that should be touched on - the filename "FormMail.pl".
The name "formmail.pl", and the slight variants on it (capitalisation, one or two "m"s, etc...) are all well-known to spammers, hackers & the like. You can safely rename the file to whatever you like, making the same change to the 'action="filename.pl"' part of your form.
This tip does fall under the "security-by-obscurity (which is no security at all)" blanket, but experience has shown that it does foil many a script kiddie.