Hi Chris,

This doesn't seem to do what I'm looking for. If I understand your script
correctly, there appear to be specific fields defined here and no
opportunity to submit form field names other than ones listed in the
script. MAILTO.EXE doesn't care what field names are fed to it, or for that
matter, how many fields are submitted to it. It will spit out a list of
field names along with the corresponding field data -- very flexible. 

        'any_field_name_whatsoever' = 'form_data_in_any_field_name_whatsoever'
        'another_oddball_field' = 'form_data_in_another_oddball_field'

I was wondering if the same can be done with Perl.

Tim




At 06:22 PM 9/26/01 -0400, you wrote:
>On Wed, 26 Sep 2001, Musar Information Network wrote:
>
>> If you're familiar with MAILTO.EXE that's all I want to do.
>
>Never heard of it... :/
>
>> It should be really simple except I'm at a loss because I usually
>> define the variables to specifically match form data and in this case
>> it needs to be flexible enough to handle a variety of different field
>> names and a various number of fields.
> 
>Ok then, here's excerpts from a script I finished debugging yesterday.
>It's meant to receive input from an error page's form (a 404 handler),
>grab all of the data from that page, including both the form data and
>anythign I can glean from the environment, and then dump it into an email
>& redirect the web user to a different page on success. This is, broadly,
>the same sort of thing you're trying to do, I think. Here we go:
>
>    #!/usr/bin/perl -w
>
>    use strict;
>    use CGI;
>    use MIME::Lite;
>
>    # 
>    # data dictionary
>    # grab info from the environment & parameters,
>    # using backups & default values as needed
>    # note that most are dynamic, but some, such as $to,
>    # are hard-coded for reasons of security & robustness.
>    # 
>    my $cgi        = new CGI;
>    my $server     = $ENV{'SERVER_NAME'}       || "domain.com";
>    my $referer    = $ENV{'HTTP_REFERER'}      || "unavailable";
>    my $document   = $ENV{'DOCUMENT_URI'}      || $ENV{'REQUEST_URI'} ||
"uri unavailable";
>    my $remoteaddr = $ENV{'REMOTE_HOST'}       || $ENV{'REMOTE_HOST'} ||
"unavailable";
>    my $query      = $ENV{'QUERY_STRING'}      || "unavailable";
>    my $date_gmt   = $cgi->param('date_gmt')   || $ENV{'DATE_GMT'}    ||
gmtime;
>    my $date_local = $cgi->param('date_local') || $ENV{'DATE_LOCAL'}  ||
localtime;
>    my $mailsrv    = "mail.domain.com";
>    my $to         = '[EMAIL PROTECTED]';
>    my $from       = $cgi->param('email')      || "web-user\@$server";
>       $from = "$from\@nowhere" unless ($from =~ m/\@/);
>    my $subject    = $cgi->param('subject')    || "Error Report";
>    my $name       = $cgi->param('name')       || "anonymous";
>    my $phone      = $cgi->param('phone')      || "not provided";
>    my $fax        = $cgi->param('fax')        || "not provided";
>    my $contact    = $cgi->param('method')     || "not provided";
>    my $return_url = $cgi->param('return')     || "/misc/error_thanks.html";
>    my $comments   = $cgi->param('comments')   || "none provided";;
>
>    #
>    # generate the main message contents for the email
>    #
>    my $message_body = qq{
>        Information submitted by the web user:
>        Name:                       $name
>        Email:                      $from
>        Phone:                      $phone
>        Fax:                        $fax
>        Preferred contact method:   $contact
>        GMT time noted:             $date_gmt
>        Local time noted:           $date_local
>        Referring page:             $referer
>        Query string:               $query
>        Comments:
>            $comments
>        Other data:
>
>        Hidden variables from the web page:
>    };
>
>    #
>    # get the form data, then the environment data
>    #
>    foreach $name ( $cgi->param() ) {
>        my $value      = $cgi->param( -name=> $name );
>        $message_body .= "      $name: \t$value\n";
>    }
>
>    $message_body .= "\n\nEnvironment variables from the web client:\n";
>    foreach $name (sort keys %ENV) {
>        my $value      = $ENV{$name};
>        $message_body .= "        $name: \t$value\n";
>    }
>
>    #
>    # actually prepare & send mail
>    #
>    my $msg = new MIME::Lite (
>              From     => $from,
>              To       => $to,
>              Type     => 'text/plain',
>              Subject  => "$subject - $document - $remoteaddr",
>              Data     => $message_body,
>    );
>    $msg->send;
>
>    #
>    # redirect to a new page
>    #
>    print "Location: http://www.domain.com/$return_url\n\n";;
>
>Etc. Provided that you have MIME::Lite (and maybe Net::SMTP, I forget), or
>can get what you need, this is running code. You should be able to modify
>the parameters grabbed, and the format they're translated into (everything
>that gets put into $message_body) so suit your needs. 
>
>If this helps you but you get stuck, let me know & maybe I can help.
>
>Likewise, if someone smarter than me notices any gaffes I've made I'd be
>eager to tighten this up, but at least it's known to work...
>
>
>-- 
>Chris Devers                     [EMAIL PROTECTED]
>
>
>_______________________________________________
>Perl-Win32-Web mailing list
>[EMAIL PROTECTED]
>http://listserv.ActiveState.com/mailman/listinfo/perl-win32-web
>

_______________________________________________
Perl-Win32-Web mailing list
[EMAIL PROTECTED]
http://listserv.ActiveState.com/mailman/listinfo/perl-win32-web

Reply via email to