Form-to-email gateway script that works with Windows 2000 Server?
January 13, 2005 7:47 AM   Subscribe

I need a form-to-email gateway script that works with Windows 2000 Server (SP4) and CDONTS or CDO.SYS to send the email. I'm thinking that the ASP port of Formmail is my best bet, but since I have no experience whatsoever with Windows Servers or ASP whatsoever, I'm a bit lost. What is my best (preferably free) option?

Note: I'm an interface designer, and don't normally work with server-side stuff. If I ever have to do anything server-side, it's always been on a UNIX machine, so this Windows business is new to me (and I really would rather not go there, but I have no choice in this instance). I've used the original PERL version of Formmail in the past with great success, but this ASP flavor is a totally different animal to me. Any insight at all would be greatly helpful.
posted by ScottUltra to Computers & Internet (5 answers total)
 
Have you considered Cygwin? That way you can keep doing (most) UNIX stuff on Windows.

In particular, you could then run cgiemail to whip up a quick and safe form-to-email script.
posted by AlexReynolds at 7:58 AM on January 13, 2005


ASP 101 has some great and very easy to implement scripts for mailing. You'll want to use CDO instead of CDONTS, which is no longer supported.

Sending email is very easy to do in ASP.
< % @language=VBScript

' Associate your variables with the HTML form fields 
' you're calling from

firstName = Request.Form("firstName")
mailTo = Request.Form("email")

'Set your mail object variables

Set objMail = Server.CreateObject("CDO.Message")

objMail.To = mailTo
objMail.From = "youremail@yourdomain.com"
objMail.Subject = "Subject Line Here"
objMail.TextBody = "Your Message"

' Send your Mail

objMail.Send

' And clear your object

Set objMail = Nothing

%>
That's it. Save that code to an asp file and use that file name as the action in your HTML form.

Also, if you're familiar with PHP or Perl, I reommend using either instead of ASP.
posted by annathea at 8:00 AM on January 13, 2005


Since you're sending email, I would definitely recommend doing something to stop, or at least make more difficult a Cross-Site Scripting attack.

Wrap the entire thing in something like:


if len(trim(Request.Cookies("SessionGuid") & " ")) > 0 then
{{code here}}

else
  response.write "This form requires your browser to allow cookies"
end if


That way you can at least make sure it's a browser that's on your page that is sending email, and not some bot proggie that exploits sendmail forms.

(The above code is for ASP. I'd recommend doing the same thing regardless of which language you end up using)
posted by icey at 8:42 AM on January 13, 2005


It's an older component that hasn't been updated in a few years, but it works (on 2k, and 2k3) in ASP.

AspEmail.
posted by purephase at 9:13 AM on January 13, 2005


I've never used FormMail or the ASP port (I assume of formmail.php, not the FormMail PERL script), but from the implementations I've seen, it's probably better than anything you can easily bake for yourself.

I did in fact bake such a thing about three years ago, that was abstracted to use either CDONTS or ASPMail, but it's been so long since I used it that I'm not sure how to tell you how it works anymore. I doubt it's as comprehensible as any incarnation of FormMail -- wasn't really written to be understood by anyone but ASP geeks...
posted by lodurr at 11:28 AM on January 13, 2005


« Older Recommend some excellent (book or web) letterpress...   |   NYC Midtown Bar Newer »
This thread is closed to new comments.