Solved

cgi send mail

Posted on 2001-08-27
1
216 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
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

Optimize your web performance

What's in the eBook?
- Full list of reasons for poor performance
- Ultimate measures to speed things up
- Primary web monitoring types
- KPIs you should be monitoring in order to increase your ROI

Question has a verified solution.

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

It is becoming increasingly popular to have a front-page slider on a web site. Nearly every TV website,  magazine or online news has one on their site, and even some e-commerce sites have one. Today you can use sliders with Joomla, WordPress or …
A quick Powershell script I wrote to find old program installations and check versions of a specific file across the network.
Learn how to match and substitute tagged data using PHP regular expressions. Demonstrated on Windows 7, but also applies to other operating systems. Demonstrated technique applies to PHP (all versions) and Firefox, but very similar techniques will w…
Video by: Mark
This lesson goes over how to construct ordered and unordered lists and how to create hyperlinks.

632 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