Go Premium for a chance to win a PS4. Enter to Win

x
?
Solved

cgi send mail

Posted on 2001-08-27
1
Medium Priority
?
230 Views
Last Modified: 2013-12-25
Hi to every one,
I want to get all the fields those who typed in the form let them user send to my email id thru the submit button.
Now I?m using Apache server as well my cgi-bin path is
/usr/local/apache/cgi-bin  
It is very easy task of all of you guy?s. But I?m very
new to CGI script.
Please any one can help me it's very useful for me.
Regards,
Babu.


<html>
<head>
<meta http-equiv="Content-Language" content="en-us">
<meta http-equiv="Content-Type" content="text/html; charset=windows-1252">
<meta name="GENERATOR" content="Microsoft FrontPage 4.0">
<meta name="ProgId" content="FrontPage.Editor.Document">
<title>Name</title>
<base target="_top">
</head>

<body>

<form method="POST" name="test" enctype="text/plain" action="submit" target="_top">
  <p>Name&nbsp;&nbsp; <input type="text" name="Name" size="25"></p>
  <p>Phone&nbsp;&nbsp; <input type="text" name="Phone" size="25"></p>
  <p>E-mail&nbsp;&nbsp; <input type="text" name="Email" size="25"></p>
  <p>Subject <input type="text" name="Subject" size="25"></p>
  <p>Query&nbsp;&nbsp; <textarea rows="3" name="Query" cols="25"></textarea></p>
  <p>&nbsp;</p>
  <p>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
  <input type="submit" value="Submit" name="Submit">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
  <input type="reset" value="Reset" name="Reset"></p>
</form>

</body>

</html>
0
Comment
Question by:ganeshbabu72
1 Comment
 
LVL 1

Accepted Solution

by:
builder110697 earned 200 total points
ID: 6429664
Here's a CGI script that accepts, verifies, and uses an email address...
You should be able to adapt...

    #!/usr/bin/perl

    use CGI qw( :standard :html );
    use CGI::Carp qw( fatalsToBrowser );
    use Mail::CheckUser qw( check_email );
    use Mail::Sendmail;

    $REQUIRED="<img src=/images/reqd_flag.gif>";

    %folks = ( "Mr. Johnson",    "one\@mysite.com",
               "Ms. Donovan",    "two\@mysite.com",
               "Mr. Bhatt",      "three\@mysite.com",
               "Mrs. Dominy",    "four\@mysite.com",
               "Miss Moyer",     "five\@mysite.com",
               "Sister Mary", "six\@mysite.com");
    $default_notify = "Mr. Johnson";

    if ( param('displayed_once_already') ne "" ) {
     if ( ! check_email( param('email')) ) {
       $redo_email = "<br><font color=red> Please re-enter email address</font>";
     }
    }

    if ( ( param('email') eq "" ) || ( $redo_email ne "" ) ) {
     print header()
         . start_form()
         . hidden( 'displayed_once_already', 'true' )
         . "Enter your email address: "
         . textfield('email',"", 50), "$REQUIRED $redo_email\n"
         . popup_menu( -name=>'sendto',
                       -values=>[ sort keys %folks ],
                       -defalt=>$default_notify )
         . submit("press to continue")
         . endform()
         . "$REQUIRED Required field"
         . end_html();
    }
    else {
     my %mail = (
         To => param('email'),
         From => me@mysite.com,
         CC => me@mysite.com,
         Subject => "I have forwarded your email address to " . param('sendto'),
         Message => "Thankyou for visiting mysite.com\n\nSincerely,\nMe");
     sendmail( %mail ) || die $Mail::SendMail::error;

     %mail = (
         To => $folks{ param('sendto') },
         From => me@mysite.com,
         Subject => "New data from " . param('email'),
         Message => "New data available from " . param('email'));
     sendmail( %mail ) || die $Mail::SendMail::error;
    }
0

Featured Post

Free Tool: Subnet Calculator

The subnet calculator helps you design networks by taking an IP address and network mask and returning information such as network, broadcast address, and host range.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Making a simple AJAX shopping cart Couple years ago I made my first shopping cart, I used iframe and JavaScript, it was very good at that time, there were no sessions or AJAX, I used cookies on clients machine. Today we have more advanced techno…
In threads here at EE, each comment has a unique Identifier (ID). It is easy to get the full path for an ID via the right-click context menu. However, we often want to post a short link within a thread rather than the full link. This article shows a…
The viewer will learn how to create a basic form using some HTML5 and PHP for later processing. Set up your basic HTML file. Open your form tag and set the method and action attributes.: (CODE) Set up your first few inputs one for the name and …
In this fourth video of the Xpdf series, we discuss and demonstrate the PDFinfo utility, which retrieves the contents of a PDF's Info Dictionary, as well as some other information, including the page count. We show how to isolate the page count in a…
Suggested Courses

926 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question