Tengo el siguiente archivo cgi con código fuente en Perl y a pesar de que me aparece el mensaje "Pedido transmitido correctamente", no recibo nada por correo electrónico. ¿Alguien sabe porqué ?. Muchas gracias.
Mi servidor me ha dado esta dirección ( "/var/qmail/bin/qmail-inject ) en lugar de usr/bin/sendmail y desde ese momento me aparece el mensaje de pedido enviado, pero no llega nada.
Using perl Syntax Highlighting
#!/usr/bin/perl
#
$mailprog = "/var/qmail/bin/qmail-inject";
&ReadParse;
&processOrder;
&print_danke;
exit(0);
sub processOrder {
$boundary = time;
@str = ();
push(@str,"| $mailprog -t");
$- = 0;
foreach $str (@str) {
open(FILE, $str) || &return_failed_file_open($str);
print FILE "To: $in{'To'} ";
print FILE "From: $in{'From'} ";
print FILE "Reply-To: $in{'From'} ";
print FILE "Subject: $in{'Subject'} ";
print FILE "X-Mailer: www.mi-tiendaweb.com E-Mail-Client Version 1.0 ";
print FILE "MIME-Version: 1.0 ";
print FILE "Content-Type: multipart/mixed; boundary="_" . $boundary . "_" ";
print FILE "--_" . $boundary . "_ ";
print FILE "Content-Type: text/plain; charset="us-ascii" ";
print FILE "$in{'Message'} ";
print FILE "--_" . $boundary . "_ ";
print FILE "Content-Type: text/plain; charset="us-ascii" ";
print FILE "Content-Disposition: attachment; filename="order" . $boundary . ".osm" ";
print FILE "$in{'Attachment'} ";
print FILE "--_" . $boundary . "_ ";
close(FILE);
}
}
sub print_danke {
print "Content-type: text/html ";
print qq|
<html>
<head>
<title>$in{'Subject'}</title>
</head>
<body bgcolor="#FFFFFF" text="#000000" OnLoad="self.focus()">
<center>
<table width="100%" border="0" cellspacing="0" cellpadding="0">
<tr valign="top" align="left">
<td align="center">
<form>
<font face="Arial, Helvetica, sans-serif" size="2"><b>Pedido transmitido correctamente.</b>
<p><input type="button" value="OK" onclick="self.close()"></p>
</form>
</td>
</tr>
</table>
</center>
</body>
</html>
|;
}
sub return_failed_file_open {
print "Content-type: text/html ";
print "Couldn't open file $_[0]: $!";
exit(1); }
sub ReadParse {
if (@_) {
local (*in) = @_;
}
local ($i, $loc, $key, $val);
# Read in text
if ($ENV{'REQUEST_METHOD'} eq "GET") {
$in = $ENV{'QUERY_STRING'};
} elsif ($ENV{'REQUEST_METHOD'} eq "POST") {
read(STDIN, $in, $ENV{'CONTENT_LENGTH'});
}
# Puffern des Input
$in_buffer = $in;
@in = split(/&/,$in);
foreach $i (0 .. $#in) {
# Convert plus's to spaces
$in[$i] =~ s/+/ /g;
# Convert %XX from hex numbers to alphanumeric
$in[$i] =~ s/%(..)/pack("c",hex($1))/ge;
# Split into key and value.
$loc = index($in[$i],"=");
$key = substr($in[$i],0,$loc);
$val = substr($in[$i],$loc+1);
$in{$key} .= '' if (defined($in{$key})); # is the multiple separator
$in{$key} .= $val;
}
return 1; # just for fun
}
#
$mailprog = "/var/qmail/bin/qmail-inject";
&ReadParse;
&processOrder;
&print_danke;
exit(0);
sub processOrder {
$boundary = time;
@str = ();
push(@str,"| $mailprog -t");
$- = 0;
foreach $str (@str) {
open(FILE, $str) || &return_failed_file_open($str);
print FILE "To: $in{'To'} ";
print FILE "From: $in{'From'} ";
print FILE "Reply-To: $in{'From'} ";
print FILE "Subject: $in{'Subject'} ";
print FILE "X-Mailer: www.mi-tiendaweb.com E-Mail-Client Version 1.0 ";
print FILE "MIME-Version: 1.0 ";
print FILE "Content-Type: multipart/mixed; boundary="_" . $boundary . "_" ";
print FILE "--_" . $boundary . "_ ";
print FILE "Content-Type: text/plain; charset="us-ascii" ";
print FILE "$in{'Message'} ";
print FILE "--_" . $boundary . "_ ";
print FILE "Content-Type: text/plain; charset="us-ascii" ";
print FILE "Content-Disposition: attachment; filename="order" . $boundary . ".osm" ";
print FILE "$in{'Attachment'} ";
print FILE "--_" . $boundary . "_ ";
close(FILE);
}
}
sub print_danke {
print "Content-type: text/html ";
print qq|
<html>
<head>
<title>$in{'Subject'}</title>
</head>
<body bgcolor="#FFFFFF" text="#000000" OnLoad="self.focus()">
<center>
<table width="100%" border="0" cellspacing="0" cellpadding="0">
<tr valign="top" align="left">
<td align="center">
<form>
<font face="Arial, Helvetica, sans-serif" size="2"><b>Pedido transmitido correctamente.</b>
<p><input type="button" value="OK" onclick="self.close()"></p>
</form>
</td>
</tr>
</table>
</center>
</body>
</html>
|;
}
sub return_failed_file_open {
print "Content-type: text/html ";
print "Couldn't open file $_[0]: $!";
exit(1); }
sub ReadParse {
if (@_) {
local (*in) = @_;
}
local ($i, $loc, $key, $val);
# Read in text
if ($ENV{'REQUEST_METHOD'} eq "GET") {
$in = $ENV{'QUERY_STRING'};
} elsif ($ENV{'REQUEST_METHOD'} eq "POST") {
read(STDIN, $in, $ENV{'CONTENT_LENGTH'});
}
# Puffern des Input
$in_buffer = $in;
@in = split(/&/,$in);
foreach $i (0 .. $#in) {
# Convert plus's to spaces
$in[$i] =~ s/+/ /g;
# Convert %XX from hex numbers to alphanumeric
$in[$i] =~ s/%(..)/pack("c",hex($1))/ge;
# Split into key and value.
$loc = index($in[$i],"=");
$key = substr($in[$i],0,$loc);
$val = substr($in[$i],$loc+1);
$in{$key} .= '' if (defined($in{$key})); # is the multiple separator
$in{$key} .= $val;
}
return 1; # just for fun
}
Coloreado en 0.004 segundos, usando GeSHi 1.0.8.4