Click to See Complete Forum and Search --> : Multiple e-mail addresses DEPENDING IN THE SUBJECT
_LOBO_
06-27-2003, 06:56 AM
HI and THNX for any help.
I want to make a COMBOX and in this combox the people can make a choice depending of this choice the e-mail address change, that’s all.
more info:
My ISP use cgiemail (http://web.mit.edu/wwwdev/cgiemail/) and becouse of that I use:
method="post" action="http://xxxx/cgi-bin/cgiemail/inscription_form.txt"
Now, if I want diferent e-mails (RECEPTORS) depending of the subject (combobox) how I need to change the FORM?.
_________________________________
I FOUND THIS SCRIPT BUT DOSENT WORK ANY IDEAS WHY?
SCRIPT (http://www.sfa-news.com/insciption_form_test.htm)
Khalid Ali
06-27-2003, 09:37 AM
I am not sure how cgimail works on your server...however I'd rather change where ever you action="......."
to this
document.Mail.action="......"
_LOBO_
06-27-2003, 09:45 AM
Thanks for your responce Khalid Ali :D
Ok this is my form (http://www.sfa-news.com/test/events/insciption_form.htm)
I want to remplace the SUBJECT for a combobox and when u chose diferent subjets the recipient (email adress receptor) change to, It shold be posible I think.
* As you can see in the form I made reference to a file TXT and inside this one I put the e-mail adress so the mail is sended to this last one.
* I try the web form that I found in the web and I remplace all the actions in the form for a hotmail acount but dosen't work.
You would use CGI and set the subject to whatever the value of the selected option in the SELECT box is.
[Jona]
_LOBO_
06-30-2003, 01:45 AM
TNX Jona.
you have and example of that form ?
and can you tell me why the form that I post dosen't work?
here the link: TEST FORM (http://www.sfa-news.com/insciption_form_test.htm)
This would go in the CGI forum, because the question has nothing to do with Javascript at all. Posting a link to the page actually doesn't help all that much because we cannot see the CGI source code you've got. All you have to do is read post form data to see which option was selected and get its value. Very, very simple.
[J]ona
_LOBO_
07-03-2003, 02:33 AM
Hi Jona Thanks for stop in my question.
I think this can be done from Client Side Scripting and maybe whit some CGI changes.
if you take a look in my source (link I post before) I made this:
ACTION ="http://www.sfa-news.com/cgi-bin/cgiemail/multiples.txt
To send the e-mail inside that TXT file I have this:
To: c4XXXX@hotmail.com
Subject: test1
SO if I made diferent TXT files with diferent e-mail adrees it should work, but the main problem is that javascript need to make the choice of the file in the server (multiples.txt, multiples2.txt, multiples3.txt, etc.. )
I hope whit this information you can send me your feedback.
_LOBO_
Thank you to all for try to help me!
I would not use a database, not text files.
I would not depend on any client-side scripting, as it is not dependable for approximately 13% of your visitors.
There is a more dynamic, server-side solution to this via CGI. You needn't create multiple CGI scripts for the form. One is enough, it can do all of the processing with simple if/else statements.
[J]ona
_LOBO_
07-04-2003, 02:19 AM
But the TXT file is part of a CGI mail is not a database, inside the TXT file I put the recipient of the e-mail.
My idea to achieve this is made diferents TXT files and inside each one put a different e-mail address. In the client side use JavaScript to chose the TXT file this is choice depend from the menu (different subjects) and like this each time that Choice a different subject from a menu JavaScript choose a different TXT file ( a different e-mail address )
http://www.hostcenter.com/en/support/show.php?qid=20&language=EN
But Im newbie in Javascript :(
Originally posted by _LOBO_
My idea to achieve this is made diferents TXT files and inside each one put a different e-mail address. In the client side use JavaScript to chose the TXT file this is choice depend from the menu (different subjects) and like this each time that Choice a different subject from a menu JavaScript choose a different TXT file ( a different e-mail address )
This will make the site unuseable by approximately 13% of your visitors, who have JavaScript disabled. You should do this server-side via the CGI script. Do you know CGI?
[J]ona
_LOBO_
07-07-2003, 01:42 AM
I found this stats:
JavaScript Stats
Thu May 1 00:05:02 2003 - Sat May 31 23:55:04 2003 31.0 Days
Javascript 1.2+: 32815350 (86%)
Javascript <1.2: 128196 (0%)
Javascript false: 5170035 (13%)
http://www.thecounter.com/stats/2003/May/javas.php
If 86% of my users can have access to this form is ok. The rest can send a e-mail or send the form by fax (pdf file).
And no I don't know CGI, and I don't have idea how that can work form me, you have some samples that I can use?
Thanks in advance
Khalid Ali
07-07-2003, 11:40 AM
if(receptor=="r1"){
document.Mail.action="mailto:admin@wow.com"
}else if(receptor=="r2"){ document.Mail.action="mailto:hr@wow.com"
}
and so on...
I wouldn't suggest doing it with Javascript, but if you must...
The code you posted looks all right to me. Is there something wrong with it? (Explaining your question always helps.)
Edit: I just realized that Khalid replied to it! I thought that was you, _LOBO_. :p
[J]ona
_LOBO_
07-08-2003, 04:21 AM
Jona I don't want to be a pain in the ass but can you please tell me in wich part of my test form I need to remplace this code?
I really apprised your help and also the Khalid help.
Show me the path Jedi Master, I made a small site about star wars is pretty ugly becouse it was my first site in flash but you can take a look, and please wait untill all the ships load the first time after that it will better when they fly I forgot to make a PRELOADING :(
Star Wars (http://212.147.1.12/mm06_2001/Roos/)
Doesn't your form already have this code in the process() function?
[J]ona
_LOBO_
07-09-2003, 01:56 AM
No, and I don't have a clue what I need to remplace.
_LOBO_
----------------------------------------------------------------------
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
<title></title>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
<SCRIPT LANGUAGE="JavaScript">
<!-- This script and many more are available free online at -->
<!-- The JavaScript Source!! http://javascript.internet.com -->
<!-- Begin
function getCookie(name){
var cname = name + "=";
var dc = document.cookie;
if (dc.length > 0) {
begin = dc.indexOf(cname);
if (begin != -1) {
begin += cname.length;
end = dc.indexOf(";", begin);
if (end == -1) end = dc.length;
return unescape(dc.substring(begin, end));
}
}
var blank = "";
return blank;
}
function setCookie(name, value, expires) {
document.cookie = name + "=" + escape(value) +
((expires != null) ? "; expires=" + expires.toGMTString() : "")
+ "; path=/";
}
function setName() {
var expdate = new Date ();
expdate.setTime (expdate.getTime() + (24 * 60 * 60 * 1000 * 365));
var prompt=i = document.Mail.name.value;
setCookie("name", i, expdate);
}
function getName() {
if(getCookie("name") != null) {
document.Mail.Name.value = getCookie("emailname");
}
}
function getInfo() {
var now= new Date();
document.Mail.Info.value = "Browser: " + navigator.userAgent;
document.Mail.Info.value += "Date:" + now;
}
function checkMultiple() {
if (getCookie("emailsent") == 'true') return true;
else return false;
}
function process() {
setCookie("emailsent", "true");
with (document.Mail) {
if (Subject.selectedIndex == 1) action = "http://www.sfa-news.com/cgi-bin/cgiemail/sapo.txt";
else if (Subject.selectedIndex == 2) action = "http://www.sfa-news.com/cgi-bin/cgiemail/sapo1.txt";
else if (Subject.selectedIndex == 3) action = "http://www.sfa-news.com/cgi-bin/cgiemail/sapo2.txt";
else if (Subject.selectedIndex == 4) action = "http://www.sfa-news.com/cgi-bin/cgiemail/sapo3.txt";
else action = "mailto:antispammer@earthling.net?subject=TJS - Other";
}
}
function formCheck() {
var passed = false;
with (document.Mail) {
if (Subject.selectedIndex == 0) {
alert("Please pick a subject.");
Subject.focus();
}
else if (Name.value == "") {
alert("Please inlcude your name.");
Name.focus();
}
else if (checkMultiple()) {
if (confirm("You just sent an e-mail from this form, are you sure you want to send another?")) {
process();
passed = true;
}
}
else {
process();
passed = true;
}
}
return passed;
}
// End -->
</SCRIPT>
</head>
<body>
<FONT FACE = "Times" SIZE = 3>
Any thing you would like to tell us? Any comments, suggestions, or questions?
<BR>
<DD>
If you are using Internet Explorer or would rather mail directly, then click <A HREF = "mailto:antispammer@earthling.net?subject=TJS - Mail">here</A>.
</DD>
<BR>
<FORM NAME = "Mail" ACTION = "http://www.sfa-news.com/cgi-bin/cgiemail/sapo.txt" METHOD = "POST" ENCTYPE = "text/plain" onSubmit="return formCheck();">
<font face = "Times" size = 3>
<input type = "hidden" size = 0 name = "Info">
</font>
<TABLE BORDER = 0 CELLPADDING = 10 CELLSPACING = 0>
<TR><TD>
Name:
<INPUT TYPE = "text" NAME = "Name" onChange = "setName()">
</TD><TD ALIGN = RIGHT >
Subject:
<select name = "Subject">
<option select>Please Select A Subject</option>
<option>1. Comment</option>
<option>2. Question</option>
<option>3. Suggestion</option>
<option>4. Broken Link</option>
<option>5. None of the above</option>
</select>
</TD>
</TR>
<TR>
<TD COLSPAN = 2>
Comments, questions, suggestions, broken links, anything!! :
<BR><BR>
<TEXTAREA NAME = "Comments, Suggestions" COLS = 75 ROWS = 6>
</TEXTAREA>
</TD>
</TR>
</TABLE>
<CENTER>
<TABLE>
<TR>
<TD align=center>
<INPUT TYPE = "submit" VALUE = "Send">
</TD>
</TR>
</TABLE>
</FORM>
<SCRIPT LANGUAGE="JavaScript">
<!-- Begin
getInfo();
getName();
// End -->
</SCRIPT>
</FONT>
<p><center>
<font face="arial, helvetica" size="-2">Free JavaScripts provided<br>
by <a href="http://javascriptsource.com">The JavaScript Source</a></font>
</center><p>
<!-- Script Size: 4.15 KB -->
</body>
</html>
Brendan Nolan
07-09-2003, 03:48 AM
If I understand this right you have a CGI form that your ISP hosts and you are given instructions on how to use it. The instructions will probably include a few variables such as "recipient", "subject", "name" (of the person submitting the form) and maybe a few options on how you need your email to look, and what pages you use for error reporting etc. Then any other variables that you pass to the CGI script will just be sent through the email automatically?
And you have a few different email addreses that relate to differant departments? If somebody selects "Accounting" you might want the message to go to "accounting@mydomain.com".
If this is so then why don't you do this? ---
<select name="recipient">
<option value="accounting@mydomain.com.au">Accounting</option>
<option value="payroll@mydomain.com.au">Payroll</option>
<option value="orders@mydomain.com.au">Orders</option>
</select>
Or, I am not really sure what you are using these multiple1.txt things for.. but...
<select name="recipient">
<option value="multiple1.txt">Accounting</option>
<option value="multiple2.txt">Payroll</option>
<option value="multiple3.txt">Orders</option>
</select>
No JavaScript required - will work with almost every single browser out there!
I never understood what _LOBO_ wanted in the first place--this is why I have not been of much help.
[J]ona
_LOBO_
07-10-2003, 03:10 AM
hi Brendan:
That is exactly what I want but to send the e-mail I use mailCGI that is why I don’t want to use:
<option>value="accounting@mydomain.com.au">Accounting</option>
but instead
<option>
value="www.MYDOMAIN.com/accounting.txt">Accounting</option>
--inside this txt file is the mail address from the accounting department so I need to create a TXT file for each department.
--in conclusion if I chose the department in the menu (ex: accounting) and I write some problem for this department in the text area <textarea name="textarea"></textarea> this e-mail should go to this department.
--QUESTION: If I want to achieve this is should be something like this?
<option>
value="action="http://www.MYDOMAIN.com/cgi-bin/cgiemail/accounting.txt">Accounting</option>
Jona I hope this explanation helps if you think is not clear let me know.
Brendan Nolan
07-10-2003, 03:53 AM
Why do you want the email addresses to be in a text file instead of the HTML?
--QUESTION: If I want to achieve this is should be something like this?
<option>
value="action="http://www.MYDOMAIN.com/cgi-bin/cgiemail/accounting.txt">Accounting</option>
Does this mean that you want the form to submit to the text file instead of the CGI script?
-Question
Does your CGI script have some variable that can be recieved that tells it which text file to use?
-Question
You know that you can most likely specify more than one email address in the recipient field like so---
<option value="accounts@mydomain.com.au,payroll@mydomain.com.au">Accounts & Payroll</option>
We still don't quite know exactly what your situation is!
Originally posted by _LOBO_
Jona I hope this explanation helps if you think is not clear let me know.
That's what I thought the whole time, but when I suggested it, you said that's not what you wanted:
Originally posted by Jona (me!)
There is a more dynamic, server-side solution to this via CGI. You needn't create multiple CGI scripts for the form. One is enough, it can do all of the processing with simple if/else statements.
You could simply have one CGI script that will send the email to a different recipient depending on which option was chosen. But the options' values would have to be value="name_of_department" instead of value="email@address.domain"
[J]ona
Brendan Nolan
07-10-2003, 08:01 PM
I have a feeling that he is not able to edit the CGI script - I think it is just some free tool like Form2Mail (by Matt's Script Archive) that a lot of ISPs host for their clients to use. Also most ISPs are not very keen for people to host their own CGI scripts with them as they can pose security issues.
Originally posted by Brendan Nolan
I have a feeling that he is not able to edit the CGI script - I think it is just some free tool like Form2Mail (by Matt's Script Archive) that a lot of ISPs host for their clients to use. Also most ISPs are not very keen for people to host their own CGI scripts with them as they can pose security issues.
If you're willing to help him. Shoot for it. ;)
[J]ona
_LOBO_
07-11-2003, 02:46 AM
Hi Brendan,
-Question
Does your CGI script have some variable that can be received that tells it which text file to use?
* Ok here is how it works the CGI in my server.
( http://www.hostcenter.com/en/support/show.php?qid=20&language=EN ) and yes is a free tool that I can't change. The e-mail Address need to be in the TXT file because that is the way it works with this CGI tool, so when I send the e-mail to this TXT file the CGI read the address inside and send the mail
<form name="form1" method="post" action="http://www.MYHOST.com/cgi-bin/cgiemail/ACCOUNTING.txt">
* And this is the FREE CGI TOOL that I have to send e-mails
http://web.mit.edu/wwwdev/cgiemail/
-Question
You know that you can most likely specify more than one email address in the recipient field like so---
* Yes I know but if I understand how my MAILCGI works I need to put one e-mail address for each TXT file. That is why I need diferent TXT for each recipient
AND SORRY FOR MY BAD ENGLISH! Jona and Brendan
Brendan Nolan
07-11-2003, 04:12 AM
Okay, I have had a look at the instructions (http://www.hostcenter.com/en/support/show.php?qid=20&language=EN) and at last I understand!
This is the kind of code that you need to put into mailtemp.txt
-------
To: accounting@yourdomain.com
Subject: Mail From Website
Name: [yourname]
Comments: [comments]
-------
But I think that you should be able to go like this...
-------
To: [department]@yourdomain.com
Subject: Mail From Website
Name: [yourname]
Comments: [comments]
-------
And have a feild on the HTML form that has a dropdown as follows (MUST be named "department")
-------
<select name="department">
<option value="accounting">Accounting</option>
<option value="payroll">Payroll</option>
<option value="orders">Orders</option>
</select>
--------
This way the email address is not even in the HTML; preventing spam robots from getting it.
The method I described above should work fine (I hope) and will work on pretty much all browsers. If not then you will need to make an extra text file for each department, and then do some JavaScript to change the action of the form to whichever dropdown is selected.
Hope that this has helped!
_LOBO_
07-11-2003, 04:33 AM
Thank you ! Brendan I will try that code but I’m still have a question and I don't want to be ungrateful because your code is really good.
But how can I Achieve this:?
B]and then do some JavaScript to change the action of the form to whichever dropdown is selected.[/B]
Because the thing I was trying to do from the beginning :D was make the dropdown thing and change the action in the the form.
one more thing, Thanks for read my link.
Brendan Nolan
07-11-2003, 05:04 AM
Okay, well first I want to say that I think it is silly to use JavaScript to do this when there is a 100% solid server side solution.... but
<script language="JavaScript">
<!--
// config
// enter the name of the form below
var formname = "mailform";
// enter the url of the parent directory that the form handler is in
var handler_dir = "http://www.MYHOST.com/cgi-bin/cgiemail/";
function changeAction(textfile){
document[formname].action=handler_dir+textfile;
}
//-->
</script>
<form name="mailform" action="http://www.MYHOST.com/cgi-bin/cgiemail/accounting.txt" method="GET">
<select name="department" onChange="changeAction(this.value)">
<option value="accounting.txt" selected>Accounting</option>
<option value="payroll.txt">Payroll</option>
<option value="orders.txt">Orders</option>
</select>
<br>
<textarea name="message">Type message here.</textarea>
<input type="submit" value="Send Email" name="submit">
</form>
To my knowledge that should work fine - I tested it on IE 5.2.2 on Mac OS X Jaguar 10.2.4. However I am sure I have done something here that one of the more experienced JavaScript gurus like Dave could improve on.
The text file referanced in the form tag should be the same one that has the selected tag on it in the dropdown box.
Brendan Nolan
07-11-2003, 05:21 AM
Originally posted by Khalid Ali
I am not sure how cgimail works on your server...however I'd rather change where ever you action="......."
to this
document.Mail.action="......"
Doesn't the with (document.Mail) {} thing cover this?
_LOBO_
07-11-2003, 07:01 AM
Thank you Brendan, this afternoon I will play with your code, and thank you for all your help. :D
I am not sure how cgimail works on your server...however I'd rather change where ever you action="......."
Doesn't the with (document.Mail) {} thing cover this?
I don't understand your question, Khalid wrote that code but I don't have a clue how it works.