View Full Version : Copy form info from Javascript to Perl/CGI

01-28-2005, 05:51 PM
I have about 50 forms (HTML/Javascript) that send E-Mail using the typical Javascript code: (urlText is the MAILTO info)
window.location.href = urlText;

This was developed on a system where Perl/CGI was not made available to others than a systems group.

Problem now is that many E-Mails are too long for Outlook/IE? to mail. Seems there is a limit of about 2000 characters. I expect that the Perl/CGI side has a much larger limit??

I have a shared function that compiles the urlText and would like to simply copy urlText from that Javascript function to Perl/CGI routine which will then Mail with Perl.

How might one do that directly from Javascript? I don't wish to return to the HTML form to execute the mailing.

Appriciate your help.

Willy Duitt
01-29-2005, 06:34 PM
From the little information you have provided I can only assume that the form actions are using the mailto protocol and your problems arise when trying to forward email to multiple address while using one long comma delimted string which you are correct will break at around 2056 characters (Internet Explorer) when using not only the mailto protocol but the get method as well since this will create one long URI...

Your solution would be to change the form actions to point towards your cgi form handler script and use serverside to send the mail rather than the clients email application...


01-29-2005, 08:11 PM

Thanks for responding.

What I'd like to do is preserve the JS form input, validating, etc. but use CGI/Perl to send the e-mail. At last count there are 67 forms the need changing. There is one common thread, I did something right, that gets as entries to a common/separate JS function -- the to, from, cc, bcc, info plus the body. This routine then builds the mail data as needed. I can easily change that routine but changing all forms to cgi is not feasable with my avail time.

Can I do something like this:

Build urlText within this one JS function as if for CGI Mail not JS MAILTO. Add this type code to that same JS function.

var eMail = eval('http://www.xxxyyy.com/cgi-bin/script.pl?firstname=' + urlText);
document.location.href = eMail;

With the script.pl accepting the completed mail file and sending it to MAIL.
Or could that code be changed to pipe (|) the urlText directly to MAIL.

I never make it easy.