i have one problem.i use cgi to send email but the coding is in perl.when i send enewletter in bulk using the coding, there is error message occur as below stated:
"Internal Server Error
The server encountered an internal error or misconfiguration and was unable to complete your request.
Please contact the server administrator, 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. "
why is this happening, the email still can be send despite of this error.why is this error message appear?
this is the coding:
[coding]
use DBI; #the perl database module
use Net::SMTP;
read(STDIN, $buffer, $ENV{'CONTENT_LENGTH'});
@pairs = split(/&/, $buffer);
foreach $pair (@pairs) {
($name, $value) = split(/=/, $pair);
$value =~ tr/+/ /;
$value =~ s/%([a-fA-F0-9][a-fA-F0-9])/pack("C", hex($1))/eg;
if ($INPUT{$name}) { $INPUT{$name} = $INPUT{$name}.",".$value; }
else { $INPUT{$name} = $value; }
}
$pid = fork();
print "Content-type: text/html \n\n fork failed: $!" unless defined $pid;
if ($pid) {
my $subject;
my $sender_uid;
$subject = $INPUT{'subject'};
$sender_uid = $INPUT{'sender_uid'};
$sender_uname = $INPUT{'sender_uname'};
$ip = $INPUT['ip'];
# connect to mysql
my $dbh = DBI->connect('DBI:mysql:database=apple:hostname=localhost','appleql','apple');
my $RowAffected = $dbh->do("INSERT INTO apple_mailing_report SET title='$subject',uid='$sender_uid',date=NOW()") or die "Can't connect";
my $log = $dbh->do("INSERT INTO apple_en_activity SET date=now(),time=now(),ip='$ip',login='$sender_uname',activity='Newsletter'") or die "Can't connect";
$dbh->disconnect();
print "Content-type: text/html \n\n";
print "<html>\n";
print "<head>\n";
print " <title>Administration</title>\n";
print " <link rel=\"stylesheet\" type=\"text/css\" href=\"style.css\">\n";
print "</head>\n";
print "<body>\n";
print "<br><br><br><center>\n";
print "<table width=\"280\">\n";
print "<tr>\n";
print " <td width=280 valign=top>\n";
print " \n";
print "<table width=\"280\" border=\"1\" cellspacing=\"0\" cellpadding=\"3\" bordercolor=\"#808080\" bordercolorlight=\"black\" bordercolordark=\"white\">\n";
print "<tr>\n";
print " <td bgcolor=\"#0000A0\"><font color=\"white\"><b>Send Status</b></td>\n";
print "</tr>\n";
print "<tr>\n";
print " <td bgcolor=\"#C0C0C0\"><br><center>Success!<BR>The message was sent.\n";
print " <P><form><input type=\"button\" value=\"Return\" onClick=\"history.go(-1)\"></form></td>\n";
print "</tr>\n";
print "</table>\n";
print "\n";
print " </td>\n";
print "</tr>\n";
print "</table>\n";
print "</center>\n";
print "</body>\n";
print "</html>";
exit(0);
}
else {
close (STDOUT);
open(LIST,"$INPUT{'address_file'}");
@addresses=<LIST>;
close(LIST);
foreach $line(@addresses) {
chomp($line);
my $ServerName = "relay.apple.com";
# Connect to the server
$smtp = Net::SMTP->new($ServerName);
die "Couldn't connect to server" unless $smtp;
my $MailFrom = $INPUT{'from'};
my $MailTo = $line;
$smtp->mail( $MailFrom );
$smtp->to( $MailTo );
# Start the mail
$smtp->data();
# Send the header.
$smtp->datasend("To: $line\n");
$smtp->datasend("From: $INPUT{'from'}\n");
$smtp->datasend("Subject: $INPUT{'subject'}\n");
$smtp->datasend("MIME-Version: 1.0\n");
$smtp->datasend("Content-Type: text/html\n");
$smtp->datasend("Content-Transfer-Encoding: 7bit\n\n");
$smtp->datasend("<html>\n");
$smtp->datasend("<head>\n");
$smtp->datasend("<title>eHomemaker.net</title>\n");
$smtp->datasend("</head>\n");
$smtp->datasend("<body>\n");
# Send the message
$smtp->datasend("$INPUT{'body'}");
$smtp->datasend("</body>\n");
$smtp->datasend("</html>");
$smtp->datasend("\n\n");
# Send the termination string
$smtp->dataend();
$smtp->quit();
}
}
[/coding]
"Internal Server Error
The server encountered an internal error or misconfiguration and was unable to complete your request.
Please contact the server administrator, 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. "
why is this happening, the email still can be send despite of this error.why is this error message appear?
this is the coding:
[coding]
use DBI; #the perl database module
use Net::SMTP;
read(STDIN, $buffer, $ENV{'CONTENT_LENGTH'});
@pairs = split(/&/, $buffer);
foreach $pair (@pairs) {
($name, $value) = split(/=/, $pair);
$value =~ tr/+/ /;
$value =~ s/%([a-fA-F0-9][a-fA-F0-9])/pack("C", hex($1))/eg;
if ($INPUT{$name}) { $INPUT{$name} = $INPUT{$name}.",".$value; }
else { $INPUT{$name} = $value; }
}
$pid = fork();
print "Content-type: text/html \n\n fork failed: $!" unless defined $pid;
if ($pid) {
my $subject;
my $sender_uid;
$subject = $INPUT{'subject'};
$sender_uid = $INPUT{'sender_uid'};
$sender_uname = $INPUT{'sender_uname'};
$ip = $INPUT['ip'];
# connect to mysql
my $dbh = DBI->connect('DBI:mysql:database=apple:hostname=localhost','appleql','apple');
my $RowAffected = $dbh->do("INSERT INTO apple_mailing_report SET title='$subject',uid='$sender_uid',date=NOW()") or die "Can't connect";
my $log = $dbh->do("INSERT INTO apple_en_activity SET date=now(),time=now(),ip='$ip',login='$sender_uname',activity='Newsletter'") or die "Can't connect";
$dbh->disconnect();
print "Content-type: text/html \n\n";
print "<html>\n";
print "<head>\n";
print " <title>Administration</title>\n";
print " <link rel=\"stylesheet\" type=\"text/css\" href=\"style.css\">\n";
print "</head>\n";
print "<body>\n";
print "<br><br><br><center>\n";
print "<table width=\"280\">\n";
print "<tr>\n";
print " <td width=280 valign=top>\n";
print " \n";
print "<table width=\"280\" border=\"1\" cellspacing=\"0\" cellpadding=\"3\" bordercolor=\"#808080\" bordercolorlight=\"black\" bordercolordark=\"white\">\n";
print "<tr>\n";
print " <td bgcolor=\"#0000A0\"><font color=\"white\"><b>Send Status</b></td>\n";
print "</tr>\n";
print "<tr>\n";
print " <td bgcolor=\"#C0C0C0\"><br><center>Success!<BR>The message was sent.\n";
print " <P><form><input type=\"button\" value=\"Return\" onClick=\"history.go(-1)\"></form></td>\n";
print "</tr>\n";
print "</table>\n";
print "\n";
print " </td>\n";
print "</tr>\n";
print "</table>\n";
print "</center>\n";
print "</body>\n";
print "</html>";
exit(0);
}
else {
close (STDOUT);
open(LIST,"$INPUT{'address_file'}");
@addresses=<LIST>;
close(LIST);
foreach $line(@addresses) {
chomp($line);
my $ServerName = "relay.apple.com";
# Connect to the server
$smtp = Net::SMTP->new($ServerName);
die "Couldn't connect to server" unless $smtp;
my $MailFrom = $INPUT{'from'};
my $MailTo = $line;
$smtp->mail( $MailFrom );
$smtp->to( $MailTo );
# Start the mail
$smtp->data();
# Send the header.
$smtp->datasend("To: $line\n");
$smtp->datasend("From: $INPUT{'from'}\n");
$smtp->datasend("Subject: $INPUT{'subject'}\n");
$smtp->datasend("MIME-Version: 1.0\n");
$smtp->datasend("Content-Type: text/html\n");
$smtp->datasend("Content-Transfer-Encoding: 7bit\n\n");
$smtp->datasend("<html>\n");
$smtp->datasend("<head>\n");
$smtp->datasend("<title>eHomemaker.net</title>\n");
$smtp->datasend("</head>\n");
$smtp->datasend("<body>\n");
# Send the message
$smtp->datasend("$INPUT{'body'}");
$smtp->datasend("</body>\n");
$smtp->datasend("</html>");
$smtp->datasend("\n\n");
# Send the termination string
$smtp->dataend();
$smtp->quit();
}
}
[/coding]