Solved

cgi send mail

Posted on 2001-08-27
1
205 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 50 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

How to run any project with ease

Manage projects of all sizes how you want. Great for personal to-do lists, project milestones, team priorities and launch plans.
- Combine task lists, docs, spreadsheets, and chat in one
- View and edit from mobile/offline
- Cut down on emails

Join & Write a Comment

Batch, VBS, and scripts in general are incredibly useful for repetitive tasks.  Some tasks can take a while to complete and it can be annoying to check back only to discover that your script finished 5 minutes ago.  Some scripts may complete nearly …
This article will show, step by step, how to integrate R code into a R Sweave document
Learn the basics of while and for loops in Python.  while loops are used for testing while, or until, a condition is met: The structure of a while loop is as follows:     while <condition>:         do something         repeate: The break statement m…
This tutorial will teach you the core code needed to finalize the addition of a watermark to your image. The viewer will use a small PHP class to learn and create a watermark.

707 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

Need Help in Real-Time?

Connect with top rated Experts

21 Experts available now in Live!

Get 1:1 Help Now