Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 3 of 3
  1. #1
    New to the CF scene
    Join Date
    Apr 2010
    Posts
    1
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Problem with form posting script

    The script I am using is supposed to take a simple HTML form and e-mail me the contents at apesquaregraphics@gmail.com, and then produce a "Thank You" confirmation page. When I post the form, I can't figure out how to get it to actually send me the email. It created the Thank You page, but doesn't send the email. Please help! Here is the script:

    #!/usr/bin/perl
    use CGI::Carp qw(fatalsToBrowser);

    # The following accepts the data from the form and splits it into its component parts

    if ($ENV{'REQUEST_METHOD'} eq 'POST') {

    read(STDIN, $buffer, $ENV{'CONTENT_LENGTH'});

    @pairs = split(/&/, $buffer);

    foreach $pair (@pairs) {
    ($name, $value) = split(/=/, $pair);
    $value =~ tr/+/ /;
    $value =~ s/%([a-fA-F0-9][a-fA-F0-9])/pack("C", hex($1))/eg;
    $FORM{$name} = $value;
    }



    # Then sends the email

    open (MESSAGE,"| /usr/sbin/sendmail -t");

    print MESSAGE "To: apesquaregraphics\@gmail.com\n"; # Don't forget to escape this @ symbol!
    print MESSAGE "From: " . $FORM{name} . ", reader\n";
    print MESSAGE "Reply-to: " . $FORM{email} . "(" . $FORM{name} . ")\n";

    print MESSAGE "Subject: Inquiry from $FORM{name} \n\n";

    print MESSAGE "$FORM{name} wrote:\n\n";
    print MESSAGE "Comment: $FORM{comment}\n\n";
    print MESSAGE "Sent by: $FORM{name} ($FORM{email}).\n";

    close (MESSAGE);

    &thank_you; #method call
    }



    #The code then goes on to generate the thank-you page

    sub thank_you {

    print "Content-type: text/html\n\n";

    print <<EndStart;

    <title>Thanks for your inquiry!</title></head>
    <body bgcolor="#ffffff" link="#000000" alink="#000000"
    vlink="#000000">
    <center><table width="624" valign="top" border="0" cellpadding="0"
    cellspacing="5"><tr><td valign="top" bgcolor="white"><img src="apesquarelogo.jpg"
    width="312" height="440" alt="ApeSquare Graphic Design"></td><td width="312"
    bgcolor="#B7FF29" valign="top"><table border="0" cellpadding="0" cellspacing="0"
    width="100%"><tr height="121" bgcolor="white"><td>&nbsp;</td></tr>
    <tr bgcolor="#B7FF29"><td valign="top">
    <img src="thankyou.jpg" alt="Thank You" width="312" height="50"><br>
    <table border="0" width="100%" cellpadding="20" cellspacing="0">
    <tr><td valign="top"><font face="georgia" size="2" color="#000000">We will process your inquiry and get back to you as soon as possible.<br>
    <a href="index.html">< Back to Previous Page</td></tr></table>


    EndStart

    print "<p></p>\n";
    print "<blockquote><em>$FORM{comment}</em></blockquote>\n\n";

    print <<EndHTML;

    </td></tr></table></td></tr></table>
    </body>
    </html>

    EndHTML

    exit(0);
    }

  • #2
    Super Moderator
    Join Date
    May 2005
    Location
    Southern tip of Silicon Valley
    Posts
    2,877
    Thanks
    2
    Thanked 164 Times in 159 Posts
    Try the formmail script from the NMS project.
    http://nms-cgi.sourceforge.net/scripts.shtml

  • #3
    Regular Coder
    Join Date
    Jul 2003
    Posts
    117
    Thanks
    0
    Thanked 17 Times in 17 Posts
    The page below might be useful

    cgi form mail example


  •  

    Posting Permissions

    • You may not post new threads
    • You may not post replies
    • You may not post attachments
    • You may not edit your posts
    •