Basically i have an Email perl script that i use on alot of my sites, which basically E-mails the filled in form to a specified e-mail address. nms_formail.pl is the name of the perl script, in case anyone has got it themselves.
I now need to change it slightly, but don't know how to......
I want to be able to email the form to different address depending on what email address is selected on the form using a tick box.
The code is wrong for those tick boxes, but you get the idea,
So when a user selects 2 of the text boxes, the email gets sent to those select tick boxes ONLY, and not the deselected on.
If anyone could shine some light on this, that would be great. If you would like me to pose the script text of the perl script please say so and i will.
Thanks again
dandaman2007
04-04-2007, 06:24 AM
COME ON PEOPLE.
SOMEONE REPLY lol
need some help he he he
Scriptage
04-11-2007, 09:18 PM
Now then. Sorry for the late reply but I have been away from these forums for quite some time.
sub doEmail{
my $email = shift;
#Enter your Email code here
#Dont forget you can access the email using $email
A "quick and dirty" solution would be to use JavaScript. If your not familiar with Perl then you probably don't want to be hacking around in the formmail script. Use the JavaScript solution temporarily to solve your problem, then play with a copy of the Perl Script in another folder or something so if you break it, it won't be catastrophic.
<HTML>
<SCRIPT LANGUAGE="JavaScript">
function makeMail() {
// RECIPIENT NUMBER ONE
if (form1.mail1.checked) {
$mail1 = form1.mail1.value + ",";
}
else {
$mail1 = "";
}
// RECIPIENT NUMBER TWO
if (form1.mail2.checked) {
$mail2 = form1.mail2.value + ",";
}
else {
$mail2 = "";
}
// RECIPIENT NUMBER THREE
if (form1.mail3.checked) {
$mail3 = form1.mail3.value + ",";
}
else {
$mail3 = "";
}
// ADDRESS TO SEND EMAILS TO
$address = $mail1 + $mail2 + $mail3; //add additional $mail4, $mail5, etc to this list for each one you add above
form1.recipient.value = $address;
<!-- change this to a hidden tag later on -->
<P><INPUT TYPE="text" NAME="recipient" VALUE="" SIZE="100">
</FORM>
</BODY>
</HTML>
You really don't want any emails listed on your webpage in any form. The reason is that there automated programs the cruise through website looking for email address (visible or hidden) and then harvest them for spam databases. If you put your address anywhere public (this forum for example) you'll notice an exponential increase in spam within a few weeks.
dandaman2007
04-16-2007, 07:31 AM
Thanks for your response WATTS,
I'm a little confused as to how the Javascript is sending the mail..... is it still using the perl script???
Thanks
Watts
04-16-2007, 10:35 AM
Yep. You're still using your Perl script as before. The JavaScript just combines addressess together in to stick in the recipients variable. I don't use the NMS script so it may not allow comma-separated, multiple email addresses. As stated, this is an example of a quick solution and not necessarily a proper solution. Copy the example above and try it out, you'll get the general idea...
dandaman2007
04-16-2007, 10:39 AM
Thank you for that mate,
It doesnt seem to be working though.... probably someting im doing wrong.
Appriceate your help,time and effort though.
Maybe if you have a working solution you could post, then that would be great, so i can addapt that.
Thanks again though
Dan
Watts
04-17-2007, 04:32 PM
Your form is looking better... have you tried submitting it with just one email (delete the preceeding and following commas) and see if it works. Get it working with one email and then try it with two (separated by a comma).
dandaman2007
04-18-2007, 03:53 AM
sorry dude...... im totally confused.....
Never done anything like this before, so i dont know how to use the commas etc.... beginners hell im sure, sorry.
Maybe a working example you may lying around lol
Watts
04-18-2007, 05:47 PM
The script seems to be working at least. I'll copy your form from your website and get a copy of NMS_formmail installed and then post a link & message after I've played with it.
Scriptage
04-22-2007, 07:57 AM
Sorry I haven't replied I've been rushed off of my feet at work. Ignore everything that Watts has said to you because it is a garbled mess. He has mixed PERL code with Javascript.
// ADDRESS TO SEND EMAILS TO
$address = $mail1 + $mail2 + $mail3; //add additional $mail4, $mail5, etc to this list for each one you add above
form1.recipient.value = $address;
Even if this code did work (which it won't as seen as Javascript doesn't use dollar signs) then the resulting concatenated string would resemble something similar to this "email1@domain.comemail2@domain.comemail3@domain.com" which is bad.
I suggest Watts goes to http://www.w3schools.com/js/default.asp to brush up on (or gain) his Javascript skills.
How Watts has managed to complicate this simple matter is beyond me.
Can you attach a copy of the file please and I will re-code the necessary bits for you and then give you a run down of what I have done and how I did it.
Kind Regards
Carl Bates
Watts
04-23-2007, 01:51 PM
Carl, you're more than welcome to help him out, if you'll actually do it (seeing how you haven't posted a reply to this thread since April 12th.)
If you don't like the help I've offered that's fine, but your editorial comments are not necessary...
- Mike.
(Texan by Birth, NOT CARL by the Grace of God)
Watts
04-23-2007, 06:53 PM
...because it is a garbled mess. He has mixed PERL code with Javascript
What?? You are smoking crack. It's JavaScript. It's perfectly acceptable to use JavaScript to set form variable values and then use Perl to handle the form submission.
Even if this code did work
It works, you didn't even bother to look at it. Okay, rename the variables to remove the dollar signs, big whoop. I bet you feel real important.
The script he is using from sourceforge called "NMS formmail" and here is the section of the readme:
Form Configuration
The action of your form needs to point towards this script (obviously), and the method must be POST or GET in capital letters. Version 1.5 of FormMail offers many new ways to code your form to tailor the resulting HTML page and the way the script performs. Below is a list of form fields you can use and how to implement them.
Necessary Form Fields
There is only one form field that you must have in your form, for FormMail to work correctly. This is the recipient field.
Field: recipient
Description: This form field allows you to specify to whom you wish for your form results to be mailed. Most likely you will want to configure this option as a hidden form field with a value equal to that of your e-mail address.
As of version 1.8, You can include multiple recipients by separating the values with commas.
Syntax: <input type=hidden name="recipient" value="email@your.host.com"> OR
<input type=hidden name="recipient" value="user@yourhost.com,user2@yourhost.com">
Exactly.
Scriptage
04-24-2007, 04:14 AM
I beg your pardon Watts, I simply saw the dollar signs and assumed you were trying to code in PERL and the code was incorrect, once again my apologies;
What?? You are smoking crack. It's JavaScript. It's perfectly acceptable to use JavaScript to set form variable values and then use Perl to handle the form submission.
Read above.
As for the Javascript solution:
If you look at the text box the string comma delimited string shows as follows ",daniel.wheeler@ekay.co.uk,,rob.noon@ekay.co.uk,,terry.zarb@ekay.co.uk," note the leading / trailing commas and the double commas between email addresses, this is more than likely bad.
There is, however, a more serious issue; passing email addresses to the CGI program will allow anybody to send ANY email address to the program thus enabling people to send spam using the form on the website, this is bad, infact very bad.
Using the comma delimited string to send emails to different addresses:
</head>
<body style="margin-top:0px">
<!-- DO NOT MOVE! The following AllWebMenus linking code section must always be placed right AFTER the BODY tag-->
<!-- ******** BEGIN ALLWEBMENUS CODE FOR menu ******** -->
<script type="text/javascript">var MenuLinkedBy="AllWebMenus [4]",awmMenuName="menu",awmBN="630";awmAltUrl="";</script><script charset="UTF-8" src="../../Menu/javascript/menu.js" type="text/javascript"></script><script type="text/javascript">awmBuildMenu();</script>
<!-- ******** END ALLWEBMENUS CODE FOR menu ******** -->
Take out the JavaScript entirely and see if Carl will customize your Perl script for you. He knows what he is doing, and can probably bang out a simple mail script for you pretty quickly (if you ask nicely [:)]).
dandaman2007
05-01-2007, 04:09 AM
Thanks watts....
So Carl...... PLEASE... PLEASE.... PRETTY PLEASE..... I LOVE YOU..... ok a little too much i think lol
Thanks guys
Scriptage
05-07-2007, 05:29 AM
Dandaman, check your private messages.
Regards
Carl
webdeveloper.com
Copyright Internet.com Inc., All Rights Reserved.