Results 1 to 5 of 5
  1. #1
    Join Date
    Feb 2004
    Posts
    25

    Unanswered: send a form via mail and get reply back

    Is it posible and how do I do this,
    Note* This question is a mail question and I am not using web application

    I want to send a form as below let say to you,
    You need to complete the form and when you click on send the result will be sent back to mymail

    I need the output in my mail
    Your name todaydate $q1 $q2 $q3

    <FORM action=mailto:mymail@mail.com method=post
    encType=text/plain>
    <input type="radio" name="q1" value="Remove">Remove
    <input type="radio" name="q1" value="Keep">Keep all<br>
    Name to be remove<BR><INPUT size=65 name=q2><BR>
    Your Comment<BR><TEXTAREA name=q3 rows=10 wrap=hard
    cols=65></TEXTAREA><BR><INPUT type=submit value=SEND>
    </FORM>

  2. #2
    Join Date
    Jan 2004
    Location
    Germany
    Posts
    167
    Code:
    <FORM action="./cgi-bin/send.cgi" method="post" enctype="text/plain">
    <input type="radio" name="q1" value="Remove">Remove 
    <input type="radio" name="q1" value="Keep">Keep all<br>
    Name to be remove<BR><INPUT size=65 name="q2"><BR>
    Your Comment<BR><TEXTAREA name="q3" rows=10 wrap=hard 
    cols=65></TEXTAREA><BR><INPUT type=submit value=SEND> 
    </FORM>
    And the Script (using sendmail):
    Code:
    #! /usr/bin/perl
    use strict;
    use warnings;
    use CGI;
    use CGI::Carp qw(fatalsToBrowser);
    
    my $cgi = CGI->new();
    print $cgi->header(-type => 'text/html');
    my %params = $cgi->Vars();
    
    my $sendmail = 'path/to/sendmail';
    my $sender   = 'anybody@domain.tld';
    my $recepient = 'rec@yourdomain.tld';
    my $subject  =  'Report from your website';
    
    my $date = get_time();
    
    open(MAIL,"| $sendmail") or die $!;
    print MAIL "From: $sender\n";
    print MAIL "To: $recepient\n";
    print MAIL "Subject: subject\n\n"; # note: two \n!!
    print MAIL "$date:\n$params{q1} $params{q2}\n$params{q3}\n";
    close MAIL;
    
    sub get_time{
      my ($secs,$Minute, $Hour, $Day, $Month, $Year) = (localtime(time))[0..5];
      my $time = sprintf("%02d.%02d.%04d %02d:%02d:%02d", $Day, ($Month + 1), ($Year + 1900), $Hour, $Minute,$secs);
      return $time;
    }# end get_date
    board.perl-community.de - The German Perl-Community

  3. #3
    Join Date
    Feb 2004
    Posts
    25
    1- I need to know how to send the the HTML FORM to recepient first

    use Mail:ender;
    use Cwd;
    my $currdor = getcwd;
    my $sender = new Mail:ender
    {
    smtp => 'dx2ml777',
    };
    $sender->OpenMultipart({
    from => 'sender@.com',
    to => 'recepient@ com',
    subject => " Update the form"} )
    or die $Mail:ender::Error,"\n";
    my $msg = " Please complete the form and when complete press send button
    ??????(THE FORM)????????????????????
    ???????????????????
    \n";
    $msg .= "<b>Thank you,<br>\n";
    $sender->Body({ctype => "text/html",
    encoding => "7bit",
    msg => "$msg" });
    $sender->Close();

    2- When the form is completed by recepient I need the out put to be send out to sender@com when he or she press send button of the html form
    Last edited by lonaj; 07-19-04 at 07:04.

  4. #4
    Join Date
    Jan 2004
    Location
    Germany
    Posts
    167
    A sample code for sending a HTML-form via mail! This is tested on my webserver...
    Code:
    #! /usr/bin/perl
    
    use strict;
    use warnings;
    use CGI;
    use CGI::Carp qw(fatalsToBrowser);
    use lib qw(./perllib);
    use Mail::Sender;
    
    my $form = qq~
    <form action="http://your-domain.com/cgi-bin/your_script.cgi" method="post">
    <input type="text" name="myField_1"><br />
    <input type="submit" value="test">
    </form>~;
    
    my $cgi = CGI->new();
    print $cgi->header(-type => 'text/html');
    
    my $sender = new Mail::Sender {
                    smtp => 'your.smtp.com',
                    on_errors => undef,
            } or die "Can't create the Mail::Sender object: $Mail::Sender::Error\n";
    
    $sender->Open({ from => 'your@address.com', to => 'repcipient@address.com,
            subject => 'HTML test',
            ctype => "text/html",
            encoding => "7bit"}) or die $Mail::Sender::Error,"\n";
    $sender->SendEx($form);
    $sender->Close();
    
    print $cgi->h1('OK');
    With that script the owner of the address recipient@address.com gets an e-mail containing just a form with one input filed and one submit-button. And within your_script.cgi you can handle the request of this form like a request from any other form.
    board.perl-community.de - The German Perl-Community

  5. #5
    Join Date
    Feb 2004
    Posts
    25

    Thumbs up

    Yes Thank you all working fine now

Posting Permissions

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