#!/usr/bin/perl
#################################################
# #
# POSTFORM: VERSION 1.0 #
# #
# Copyright: NETWAY AG #
# #
#################################################
# Define some constants
$mailprog = '/usr/lib/sendmail';
# Get the input
read(STDIN, $buffer, $ENV{'CONTENT_LENGTH'});
# Split the name-value pairs
@pairs = split(/&/, $buffer);
foreach $pair (@pairs)
{
($name, $value) = split(/=/, $pair);
# Un-Webify plus signs and %-encoding
$value =~ tr/+/ /;
$value =~ s/%([a-fA-F0-9][a-fA-F0-9])/pack("C", hex($1))/eg;
# Stop people from using subshells to execute commands
# Not a big deal when using sendmail, but very important
# when using UCB mail (aka mailx).
# $value =~ s/~!/ ~!/g;
# Uncomment for debugging purposes
# print "Setting $name to $value
";
$FORM{$name} = $value;
}
# Now send mail to $recipient
open (MAIL, "|$mailprog $FORM{'h_mailto'}") || die "Can't open $mailprog!\n";
print MAIL "From: noreply\@domain.xxx\n";
print MAIL "Subject: $FORM{'h_subject'}\n\n";
foreach $key (sort(keys(%FORM)))
{
print MAIL "$key: $FORM{$key}\n\n";
}
#print MAIL "Server protocol: $ENV{'SERVER_PROTOCOL'}\n";
#print MAIL "Remote host: $ENV{'REMOTE_HOST'}\n";
#print MAIL "Remote IP address: $ENV{'REMOTE_ADDR'}\n";
close (MAIL);
if ($FORM{'h_successurl'} ne "") {
print "Location: $FORM{'h_successurl'}\n\n";
} else {
print "Content-type: text/html\n";
print "The message has been sent!
";
print "<A HREF=\"$ENV{'HTTP_REFERER'}\">Back!</A>
";
}
wie man sieht, von netway programmiert
ich bin jetzt grad dabei, es so umzubauen, dass es für mich passt, allerdings hatte ich ständig n internal server error, auch wenn ich das script auf die erste zeile reduziere.
hab dann mal probiert, die variablennamen zu ändern, das geht noch, sobald ich aber eigene variablen einbaue, hab ich den error
wieder
die daten werden von einem formular übertragen.
so ungefähr hab ich zwar eine ahnung wies funkt, allerdings sind mir die errors etwas schleierhaft
ich post halt mein derzeit modifiziertes auch noch rein:
#!/usr/bin/perl
# Define some constants
$mailprog = '/usr/lib/sendmail';
# Get the input
read(STDIN, $buffer, $ENV{'CONTENT_LENGTH'});
# Split the name-value pairs
@pairs = split(/&/, $buffer);
foreach $pair (@pairs)
{
($name, $value) = split(/=/, $pair);
# Un-Webify plus signs and %-encoding
$value =~ tr/+/ /;
$value =~ s/%([a-fA-F0-9][a-fA-F0-9])/pack("C", hex($1))/eg;
# Stop people from using subshells to execute commands
# Not a big deal when using sendmail, but very important
# when using UCB mail (aka mailx).
# $value =~ s/~!/ ~!/g;
# Uncomment for debugging purposes
# print "Setting $name to $value
";
$FORM{$name} = $value;
}
# Now send mail to $recipient
open (MAIL, "|$mailprog $FORM{'mail'}") || die "Can't open $mailprog!\n";
print MAIL "From: $FORM{'senderMail'}\n";
print MAIL "Subject: $FORM{'subject'}\n\n";
print MAIL "$FORM{'text'}\n\n";
#print MAIL "Server protocol: $ENV{'SERVER_PROTOCOL'}\n";
#print MAIL "Remote host: $ENV{'REMOTE_HOST'}\n";
#print MAIL "Remote IP address: $ENV{'REMOTE_ADDR'}\n";
close (MAIL);
if ($FORM{'h_successurl'} ne "") {
print "Location: $FORM{'h_successurl'}\n\n";
} else {
print "Content-type: text/html\n";
print "The message has been sent!
";
print "<A HREF=\"$ENV{'HTTP_REFERER'}\">Back!</A>
";
}
|