Solved

cgi send mail

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

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

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

Suggested Solutions

The following is a collection of cases for strange behaviour when using advanced techniques in DOS batch files. You should have some basic experience in batch "programming", as I'm assuming some knowledge and not further explain the basics. For some…
This article will show, step by step, how to integrate R code into a R Sweave document
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.
Video by: Mark
This lesson goes over how to construct ordered and unordered lists and how to create hyperlinks.

920 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

15 Experts available now in Live!

Get 1:1 Help Now