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

Hi, I am trying to write a script/cgi that will take the form data from my website and send it in an email. I don't want to use the typical "mailto" HTML tag to do it. I want to kind of remain anonymous and do it in the background... I am using DreamWeaver to create my "Contact Us" page. I am using the Form tag with a Submit button. There are only 4 fields: First Name, Last Name, email, and Message. I have my website on Go Daddy. So, I may have to get some mail server info from them.?.? Or maybe the path to Perl? Here is the code from my webpage:

<form id="form1" name="form1" method="post" action="scripts/form.pl"> <table width="436" border="0" align="center" cellpadding="0" c +ellspacing="0" id="contactUs"> <tr> <td width="94">First Name</td> <td width="318"> <p> <input name="firstName" type="text" id="firstName" siz +e="20" maxlength="20" /> </p></td> </tr> <tr> <td>Last Name</td> <td><p><input name="lastName" type="text" id="lastName" si +ze="20" maxlength="20" /></p></td> </tr> <tr> <td>e-mail</td> <td><p><input name="email" type="text" id="email" value="N +ot working yet... Sorry" size="50" maxlength="50" /></p></td> </tr> <tr> <td>Message</td> <td><p><textarea name="message" id="message" cols="50" row +s="5"></textarea></p></td> </tr> <tr> <td>&nbsp;</td> <td><p> <input type="submit" name="submit" id="submit" value="Su +bmit" /> &nbsp;&nbsp; <input type="reset" name="Reset" id="button" value="Reset" + /></p></td> </tr> </table> </form>

Thanks for your help!

Replies are listed 'Best First'.
Re: Send my website form data via email
by davido (Cardinal) on Apr 21, 2013 at 14:43 UTC

    What does form.pl look like? Have you written any of it yet?

    For such a simple application you could use CGI.pm, and Mail::Sender. You will need to decide what SMTP server to send through. Your ISP may have one set up, or maybe you would like to use a gmail account. Sometimes mail sent directly from the super-huge hosting services is treated as spam by recipients, so it might be preferable to send through an SMTP service that doesn't have the godaddy domain. There is a good no-frills "just send the email" example here: Email::Sender::Simple

    As for the CGI portion, the module I recommended has pretty good documentation. There's also the (old but useful) O'Reilly book, CGI Programming with Perl. The state of the art for web applications has left that book behind, but you're asking about CGI, which is equally antiquated, and contemporary with that book. You can get a copy used for a penny, plus shipping on Amazon.

    See also: Go Daddy Support: What email or relay server should I use in my Perl code?.


    Dave

Re: Send my website form data via email
by CountZero (Bishop) on Apr 21, 2013 at 19:41 UTC
    Many webspace-providers have ready-to-use scripts to send data by mail, or at the very least some examples how to do it.

    Ask the admins if they have something already installed and where you can find it.

    A quick Google search found some hits

    CountZero

    A program should be light and agile, its subroutines connected like a string of pearls. The spirit and intent of the program should be retained throughout. There should be neither too little or too much, neither needless loops nor useless variables, neither lack of structure nor overwhelming rigidity." - The Tao of Programming, 4.1 - Geoffrey James

    My blog: Imperial Deltronics
Re: Send my website form data via email
by flyingskibiker (Initiate) on Apr 21, 2013 at 22:09 UTC

    Hello everyone.

    Thanks for the very quick responses!

    Well, I was never one to use what the hosting services provided. But I did look into it after a search (thanks for that suggestion). It's funny, I usually use the heck out of searches...

    Anywho, I used one of GoDaddy's php scripts (no idea what php is...). Seems to work OK. At least I can "open up" my site, now. Not much there, yet. If something comes up that I don't like abou the script, I'll look into something else. Though I'll tell you, my previous attempt at using the "module" thing is about the most confusing thing I've ever tried to do (using someone else's code w/o knowing the methods behind it)!

    Thanks again!
    cb

Re: Send my website form data via email
by mbethke (Hermit) on Apr 21, 2013 at 17:08 UTC

    Sorry to be a heretic here but that's something I'd recommend some PHP thing for if you don't have any experience. Much less trouble. There are several tried and tested solutions that you can just copy to your webspace and be done with it (don't ask me any names though, I'd have to duckduck as well). Trying to do this yourself without a good understanding of how the underlying modules work is likely to lead to problems like header injection vulnerabilities. Perl modules tend to have more sensible defaults than PHP so getting it wrong is not quite as easy but still ...

    That said, you could of course do a good deed for provider-side Perl support and make sure some ready-made Perl solution with its associated modules works fine on your webspace. Likewise I'd have to search for the name of any such script though.