- Código: Seleccionar todo
#!/usr/bin/perl
use CGI qw':standard :cgi-lib';
use POSIX 'strftime';
use Mail::Sendmail;
use strict;
#### Configuracion
my $to = '[email protected]'; #### Destinatario del correo
my $subject = 'MERCHANT ORDER'; #### E-MAIL asunto
my $smtp = 'correo.tudominio.net'; #### Servidor de correo
#### Fin configuracion
#### Inicializacion
my %FORM;
$FORM{$_} = '' foreach qw(
name email
comments
cardtype cardname cardnum cardexp
bfirstname blastname bemail baddress bcity bstate bzip bphone bcomments
sname saddress scity sstate szip
);
#### Programa
print header('header/html'); #### Cabecera
if ( $ENV{'REQUEST_METHOD'} ne 'POST' ) {
print "error=wrong method";
exit;
}
#### Leer los parámetros pasados por el cliente
%FORM = Vars();
#### Componer el mensaje
my $date = strftime "%a, %B %e, %Y a las %H:%M:%S", localtime;
my $mensaje = <<"MENSAJE";
---------------------------------------------------------------
ORDER SUBMITTED BY:
$FORM{name} on $date
---------------------------------------------------------------
MERCHANDISE ORDER
---------------------------------------------------------------
$FORM{comments}
---------------------------------------------------------------
CARD INFORMATION
---------------------------------------------------------------
TYPE : $FORM{cardtype}
NAME ON CARD : $FORM{cardname}
CARD NUMBER : $FORM{cardnum}
CARD EXPIRATION : $FORM{cardexp}
---------------------------------------------------------------
BILLING INFO
---------------------------------------------------------------
FIRST NAME : $FORM{bfirstname}
LAST NAME : $FORM{blastname}
EMAIL : $FORM{bemail}
ADDRESS : $FORM{baddress}
CITY : $FORM{bcity}
STATE : $FORM{bstate}
ZIP : $FORM{bzip}
PHONE : $FORM{bphone}
COMMENTS : $FORM{bcomments}
---------------------------------------------------------------
SHIPPING INFO
---------------------------------------------------------------
NAME : $FORM{sname}
ADDRESS : $FORM{saddress}
CITY : $FORM{scity}
STATE : $FORM{sstate}
ZIP : $FORM{szip}
---------------------------------------------------------------
<REMOTE HOST> $ENV{REMOTE_HOST}
<REMOTE ADDRESS> $ENV{REMOTE_ADDR}
<USER AGENT> $ENV{HTTP_USER_AGENT}
MENSAJE
#### Enviar el correo
my $from_name = "$FORM{name} <$FORM{email}>";
my %mail = (
smtp => $smtp,
From => $from_name,
'Reply-To' => $from_name,
To => $to,
Subject => $subject,
Message => $mensaje,
);
sendmail(%mail) or die $Mail::Sendmail::error;
#### Fin
print '&error=sent the email successfully';
exit;