Perl - CGI no envía el formulario

 
Vista:

CGI no envía el formulario

Publicado por Adolfo (2 intervenciones) el 02/12/2008 19:03:02
Hola,

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.

#!/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
}
Valora esta pregunta
Me gusta: Está pregunta es útil y esta claraNo me gusta: Está pregunta no esta clara o no es útil
0
Responder

RE:CGI no envía el formulario

Publicado por Joaquin Ferrero (25 intervenciones) el 02/12/2008 21:33:49
¿Existe el programa /var/qmail/bin/qmail-inject en el sistema? ¿el servidor de correo permite el envío de correo de forma no autenticada?
Valora esta respuesta
Me gusta: Está respuesta es útil y esta claraNo me gusta: Está respuesta no esta clara o no es útil
0
Comentar

RE:CGI no envía el formulario

Publicado por Adolfo (2 intervenciones) el 03/12/2008 09:37:19
Es la url que me ha facilitado mi servidor en lugar de la dirección usr/bin/sendmail.

Imagino que estará bien, porque en cuanto la puse me apareció el mensaje de "pedido enviado correctamente", cuando antes me daba un error.

¿ Hay manera de comprobar si esta dirección es correcta ?.

SI me podéis decir algo sobre lo anterior me sería de mucha utilidad. Muchas gracias.

Un saludo.
Adolfo.
Valora esta respuesta
Me gusta: Está respuesta es útil y esta claraNo me gusta: Está respuesta no esta clara o no es útil
0
Comentar