swenw: CGI Mail ich schmeis die kiste bald aus dem fenster

hallo

vielleicht kann mir ja hier jemand helfen der sich mit cgi und mail auskennt.   ok kurz zur vorgeschichte.  ich habe über netobjects ein formular gebastelt und möchte die eingegebenen daten per email erhalten. mein provider läst freie cgi zu. alles gemacht und ich bekomm immer folgende fehlermeldung

_____________________________________________________________________

Internal Server Error
The server encountered an internal error or misconfiguration and was unable to complete your request.
Please contact the server administrator, webmaster@get-it-on.de and inform them of the time the error occurred, and anything you might have done that may have caused the error.

More information about this error may be available in the server error log.

--------------------------------------------------------------------------------

Apache/1.3.19 Server at www.get-it-on.de Port 80

_____________________________________________________________________

als mailer.pl verwende ich folgenden code

#!/usr/bin/perl

#   mailer.pl-- A simple program to mail form data to an email address

#   Written in 1997 by James Marshall, james@jmarshall.com
#   For the latest, see http://www.jmarshall.com/easy/cgi/

IMPORTANT: MAKE SURE THESE TWO VALUES ARE SET CORRECTLY FOR YOU!

$mailprog= "/usr/sbin/sendmail" ;
$recipient= "info@get-it-on.de" ;      # make sure to \ escape the @

Get the CGI input variables

%in= &getcgivars ;

Open the mailing process

open(MAIL, "|$mailprog= "/usr/sbin/sendmail"; $recipient"info@get-it-on.de")
    || &HTMLdie("Couldn't send the mail (couldn't run $mailprog).") ;

Print the header information

$ENV{'HTTP_REFERER'} || ($ENV{'HTTP_REFERER'}= "http://www.get-it-on.de/erhalten") ;
print MAIL "Subject: Form data from the Web\n\n",
           "The following data was entered at $ENV{'HTTP_REFERER'}:\n\n" ;

Find length of longest field name, for formatting; include space for colon

$maxlength= 0 ;
foreach (keys %in) {
    $maxlength= length if length > $maxlength ;
}
$maxlength++ ;

Print each CGI variable received by the script, one per line.

This just prints the fields in alphabetical order.  To define your own

#   order, use something like
#     foreach ('firstname', 'lastname', 'phone', 'address1', ... ) {
foreach (sort keys %in) {

# If a field has newlines, it's probably a block of text; indent it.
    if ($in{$_}=~ /\n/) {
        $in{$_}= "\n" . $in{$_} ;
        $in{$_}=~ s/\n/\n    /g ;
        $in{$_}.= "\n" ;
    }

# comma-separate multiple selections
    $in{$_}=~ s/\0/, /g ;

# Print fields, aligning columns neatly
    printf MAIL "%-${maxlength}s  %s\n", "$_:", $in{$_} ;
}

Close the process and mail the data

close(MAIL) ;

Print an HTML response to the user

print <<EOF ;
Content-type: text/html

<html>
<body>
<h3>Your data has been sent.</h3>
</body>
</html>
EOF

exit ;

#-------------- start of &getcgivars() module, copied in -------------

Read all CGI vars into an associative array.

If multiple input fields have the same name, they are concatenated into

#   one array element and delimited with the \0 character (which fails if
#   the input has any \0 characters, very unlikely but conceivably possible).

Currently only supports Content-Type of application/x-www-form-urlencoded.

sub getcgivars {
    local($in, %in) ;
    local($name, $value) ;

# First, read entire string of CGI vars into $in
    if ( ($ENV{'REQUEST_METHOD'} eq 'GET') ||
         ($ENV{'REQUEST_METHOD'} eq 'HEAD') ) {
        $in= $ENV{'QUERY_STRING'} ;

} elsif ($ENV{'REQUEST_METHOD'} eq 'POST') {
        if ($ENV{'CONTENT_TYPE'}=~ m#^application/x-www-form-urlencoded$#i) {
            length($ENV{'CONTENT_LENGTH'})
                || &HTMLdie("No Content-Length sent with the POST request.") ;
            read(STDIN, $in, $ENV{'CONTENT_LENGTH'}) ;

} else {
            &HTMLdie("Unsupported Content-Type: $ENV{'CONTENT_TYPE'}") ;
        }

} else {
        &HTMLdie("Script was called with unsupported REQUEST_METHOD.") ;
    }

# Resolve and unencode name/value pairs into %in
    foreach (split(/[&;]/, $in)) {
        s/+/ /g ;
        ($name, $value)= split('=', $_, 2) ;
        $name=~ s/%([0-9A-Fa-f]{2})/chr(hex($1))/ge ;
        $value=~ s/%([0-9A-Fa-f]{2})/chr(hex($1))/ge ;
        $in{$name}.= "\0" if defined($in{$name}) ;  # concatenate multiple vars
        $in{$name}.= $value ;
    }

return %in ;

}

Die, outputting HTML error page

If no $title, use a default title

sub HTMLdie {
    local($msg,$title)= @_ ;
    $title= "CGI Error" if $title eq '' ;
    print <<EOF ;
Content-type: text/html

<html>
<head>
<title>$title</title>
</head>
<body>
<h1>$title</h1>
<h3>$msg</h3>
</body>
</html>
EOF

exit ;
}

#-------------- end of &getcgivars() module --------------------------

Ich hab echt keine ahnung an was es liegen könnte. da ich auch kein cgi prog kann, hoffe ich das mir einer von euch helfen kann. danke

gruß

swen

  1. hallo

    vielleicht kann mir ja hier jemand helfen der sich mit cgi und mail auskennt.   ok kurz zur vorgeschichte.  ich habe über netobjects ein formular gebastelt und möchte die eingegebenen daten per email erhalten. mein provider läst freie cgi zu. alles gemacht und ich bekomm immer folgende fehlermeldung

    _____________________________________________________________________

    Internal Server Error
    The server encountered an internal error or misconfiguration and was unable to complete your request.
    Please contact the server administrator, webmaster@get-it-on.de and inform them of the time the error occurred, and anything you might have done that may have caused the error.

    More information about this error may be available in the server error log.


    Das ist nichts brauchbares!
    Kommst Du an die LogFiles? Oder besser: Hast Du Telnet/SSH-Zugriff auf die Konsole?

    Gruß
    Reiner

  2. HI Swen,

    bin kein Progammierer, aber hier steht:

    $recipient= "info@get-it-on.de" ;      # make sure to \ escape the @

    Anscheinend muss das @ escaped werden sprich: @

    hTH

    Werner

  3. #   Written in 1997 by James Marshall, james@jmarshall.com

    Ich würde dir in Zeiten des spams dringenst vor einem Skript aus dieser Zeit abraten. Ich hab jetzt nicht drüber geguckt, aber mein 1. Eindruck ist, das es hoffnungslos veraltet ist (und vermutlich schon 1997 war).

    Struppi.

  4. hallo

    vielleicht kann mir ja hier jemand helfen der sich mit cgi und mail auskennt.   ok kurz zur vorgeschichte.  ich habe über netobjects ein formular gebastelt und möchte die eingegebenen daten per email erhalten. mein provider läst freie cgi zu. alles gemacht und ich bekomm immer folgende fehlermeldung

    _____________________________________________________________________

    Internal Server Error
    The server encountered an internal error or misconfiguration and was unable to complete your request.
    Please contact the server administrator, webmaster@get-it-on.de and inform them of the time the error occurred, and anything you might have done that may have caused the error.

    More information about this error may be available in the server error log.


    Apache/1.3.19 Server at www.get-it-on.de Port 80

    _____________________________________________________________________

    als mailer.pl verwende ich folgenden code

    #!/usr/bin/perl

    #   mailer.pl-- A simple program to mail form data to an email address

    #   Written in 1997 by James Marshall, james@jmarshall.com
    #   For the latest, see http://www.jmarshall.com/easy/cgi/

    IMPORTANT: MAKE SURE THESE TWO VALUES ARE SET CORRECTLY FOR YOU!

    $mailprog= "/usr/sbin/sendmail" ;
    $recipient= "info@get-it-on.de" ;      # make sure to \ escape the @

    Get the CGI input variables

    %in= &getcgivars ;

    Open the mailing process

    open(MAIL, "|$mailprog= "/usr/sbin/sendmail"; $recipient"info@get-it-on.de")
        || &HTMLdie("Couldn't send the mail (couldn't run $mailprog).") ;

    Print the header information

    $ENV{'HTTP_REFERER'} || ($ENV{'HTTP_REFERER'}= "http://www.get-it-on.de/erhalten") ;
    print MAIL "Subject: Form data from the Web\n\n",
               "The following data was entered at $ENV{'HTTP_REFERER'}:\n\n" ;

    Find length of longest field name, for formatting; include space for colon

    $maxlength= 0 ;
    foreach (keys %in) {
        $maxlength= length if length > $maxlength ;
    }
    $maxlength++ ;

    Print each CGI variable received by the script, one per line.

    This just prints the fields in alphabetical order.  To define your own

    #   order, use something like
    #     foreach ('firstname', 'lastname', 'phone', 'address1', ... ) {
    foreach (sort keys %in) {

    # If a field has newlines, it's probably a block of text; indent it.
        if ($in{$_}=~ /\n/) {
            $in{$_}= "\n" . $in{$_} ;
            $in{$_}=~ s/\n/\n    /g ;
            $in{$_}.= "\n" ;
        }

    # comma-separate multiple selections
        $in{$_}=~ s/\0/, /g ;

    # Print fields, aligning columns neatly
        printf MAIL "%-${maxlength}s  %s\n", "$_:", $in{$_} ;
    }

    Close the process and mail the data

    close(MAIL) ;

    Print an HTML response to the user

    print <<EOF ;
    Content-type: text/html

    <html>
    <body>
    <h3>Your data has been sent.</h3>
    </body>
    </html>
    EOF

    exit ;

    #-------------- start of &getcgivars() module, copied in -------------

    Read all CGI vars into an associative array.

    If multiple input fields have the same name, they are concatenated into

    #   one array element and delimited with the \0 character (which fails if
    #   the input has any \0 characters, very unlikely but conceivably possible).

    Currently only supports Content-Type of application/x-www-form-urlencoded.

    sub getcgivars {
        local($in, %in) ;
        local($name, $value) ;

    # First, read entire string of CGI vars into $in
        if ( ($ENV{'REQUEST_METHOD'} eq 'GET') ||
             ($ENV{'REQUEST_METHOD'} eq 'HEAD') ) {
            $in= $ENV{'QUERY_STRING'} ;

    } elsif ($ENV{'REQUEST_METHOD'} eq 'POST') {
            if ($ENV{'CONTENT_TYPE'}=~ m#^application/x-www-form-urlencoded$#i) {
                length($ENV{'CONTENT_LENGTH'})
                    || &HTMLdie("No Content-Length sent with the POST request.") ;
                read(STDIN, $in, $ENV{'CONTENT_LENGTH'}) ;

    } else {
                &HTMLdie("Unsupported Content-Type: $ENV{'CONTENT_TYPE'}") ;
            }

    } else {
            &HTMLdie("Script was called with unsupported REQUEST_METHOD.") ;
        }

    # Resolve and unencode name/value pairs into %in
        foreach (split(/[&;]/, $in)) {
            s/+/ /g ;
            ($name, $value)= split('=', $_, 2) ;
            $name=~ s/%([0-9A-Fa-f]{2})/chr(hex($1))/ge ;
            $value=~ s/%([0-9A-Fa-f]{2})/chr(hex($1))/ge ;
            $in{$name}.= "\0" if defined($in{$name}) ;  # concatenate multiple vars
            $in{$name}.= $value ;
        }

    return %in ;

    }

    Die, outputting HTML error page

    If no $title, use a default title

    sub HTMLdie {
        local($msg,$title)= @_ ;
        $title= "CGI Error" if $title eq '' ;
        print <<EOF ;
    Content-type: text/html

    <html>
    <head>
    <title>$title</title>
    </head>
    <body>
    <h1>$title</h1>
    <h3>$msg</h3>
    </body>
    </html>
    EOF

    exit ;
    }

    #-------------- end of &getcgivars() module --------------------------

    Ich hab echt keine ahnung an was es liegen könnte. da ich auch kein cgi prog kann, hoffe ich das mir einer von euch helfen kann. danke

    gruß

    swen

    also ich komme hier einfach nicht weiter. gibt es denn nicht einfach ein skript das ich ganz einfach umschreiben kann???

    gruß

    swen

  5. Hi,

    Was ist daran unklar: ?

    $recipient= "info@get-it-on.de" ;      # make sure to \ escape the @

    Ciao,
      Wolfgang

  6. Hallo Swen

    hast Du eventuell schon chmod 755 ausprobiert?

    Gruß
    Helmut Weber

    --
    -------------------------------------------
    Mode ist eine Variable, Stil eine Konstante