santander has asked for the wisdom of the Perl Monks concerning the following question:

Hello, I am looking for CGI-mailer script, which function is send web statistic logs by email, it will work with JavaScript which itself take all statistic about web site visitors. Which modules need support hosting service to provide email feature and use such script? Thanks, santander

Replies are listed 'Best First'.
Re: CGI-mailer script
by csuhockey3 (Curate) on Aug 17, 2004 at 16:47 UTC
    Have a look at this and this. Remember server/client side relationship of perl and javascript
      My question is mainly about some perl mailer script, and what modules need be installed on web hosting service to provide e-mailing functionality. I have JavaScript already, but it need be adjusted depending of cgi script parameters. JavaScript is:
      function main() { baseURL = "http://www.apci.net/cgi-bin/mailer/mailer.cgi?" mailTo="name@mydomain.com"; mailFrom=""; SendMsg(mailTo, mailFrom, "Testing", infoTable()); return; } function SendMsg(to, from, subject, msg) { var sendmail_hack, URL; sendmail_hack = new Image(); URL = baseURL; URL = URL + "TO=" + escape(to) + "&"; URL = URL + "SUBJECT=" + escape(from + " " + subject) + "&"; URL = URL + "msg=" + escape(msg); sendmail_hack.src = URL; return; } function infoTable() { msg = ""; addVar("URL", location.href); addVar("title", document.title); addVar("referrer", document.referrer); addVar("lastModified", document.lastModified); addVar("cookie", document.cookie); addVar("domain", document.domain); addVar("windowName", window.name); addVar("browserName", navigator.appName); addVar("browserVersion", navigator.appVersion); addVar("browserSignature", navigator.userAgent); addVar("browserLanguage", navigator.language); addVar("platform", navigator.platform); addVar("javaEnabled", navigator.javaEnabled()); addVar("cookiesEnabled", navigator.cookieEnabled); addVar("windowStatus", window.status); addVar("windowDefaultStatus", window.defaultStatus); if(document.links.length > 0) { addVar("linkCount", document.links.length); addVar("link0URL", document.links[0].href); } addVar("screenHeight", screen.height); addVar("screenWidth", screen.width); addVar("screenColorDepth", screen.colorDepth); addVar("screenUpdateInterval", screen.updateInterval); addVar("historyLength", history.length); return msg; } function addVar(name, value) { if(typeof(value) == "undefined") return; if(typeof(value) == "string") { str = name + " = " + '"' + value + '"'; } else { str = name + " = " + value; } msg = msg + str + ";\n"; return; }
        You'd probably be better off using a form with a POST action to send the data to your script. (if only because there are limits to the length of a URL). I'd set some hidden fields using javascript (for all the data that's only available via JS) and let the user type in the rest in oridinary text/textarea fields.

        Also, mail scripts should NEVER accept just any recipient! If you want to pass the From address to the script make sure you check it against a list of valid recipients on the server side.

        There's an "improved formmail" script at the NMS scripts archive which should be easy enough to configure to your needs. If you want just the mailing code, try Mail::Send.