Ver Mensaje Individual
  #3 (permalink)  
Antiguo 16/09/2011, 14:04
toyeslomao
 
Fecha de Ingreso: diciembre-2010
Ubicación: tenerife
Mensajes: 60
Antigüedad: 13 años, 11 meses
Puntos: 0
Respuesta: erro al envial email local

si , se que es perl pero no sabia donde ponerlo, y si es q no me cabia el codigo completo , podria ponerlo en varias veces si ves que es mejor y asi quedaria completo, vuelvo a ponerlo completo a ver q tal

1º PARTE DEL CODIGO

Código perl:
Ver original
  1. #!/usr/bin/perl
  2.  
  3. require 5.001;
  4.  
  5. $header        = "header.html";
  6. $footer        = "footer.html";
  7. $mailprogram   = "smtp.gmail.com";
  8. $returnpage    = "/";
  9. $youremail     = "[email protected]";
  10. $csvfilename   = "orders.csv";
  11. $csvquote      = "\"\"";
  12. $mode          = "FILE";
  13.  
  14.  
  15. #These are required fields.  I recommend enforcing these by javascript,
  16. #but let's just make sure here as well.
  17. @required = (
  18. 'b_first',
  19. 'b_last',
  20. 'b_addr',
  21. 'b_city',
  22. 'b_state',
  23. 'b_zip',
  24. 'b_phone',
  25. 'b_email'
  26. );
  27.  
  28. FUNCTION:   urlDecode                                      
  29. RETURNS:    The decoded string.                            
  30. PARAMETERS: An encoded string.                              
  31. PURPOSE:    Decodes a URL encoded string.                  
  32.  
  33. sub urlDecode {
  34.     my ($string) = @_;
  35.     $string =~ tr/+/ /;
  36.     $string =~ s/%([\dA-Fa-f][\dA-Fa-f])/pack ("C", hex($1))/eg;
  37.     $string =~ s/['"]/\'/g;
  38.     return ($string);
  39. }
  40.  
  41. #FUNCTION:   processCGI
  42.  
  43. sub processCGI {
  44.     local ($cgiData, $key, $value, $pair, @pairs);
  45.  
  46.    if ($ENV{'REQUEST_METHOD'} eq 'GET') { $cgiData = $ENV{'QUERY_STRING'}; }
  47.    else { $cgiData = <STDIN>; }
  48.    @pairs = split (/&/, $cgiData);
  49.    foreach $pair (@pairs) {
  50.       ($key, $value) = split (/\=/, $pair);
  51.       $key   = &urlDecode($key);
  52.       $value = &urlDecode($value);
  53.       if(defined ${$key}){
  54.          ${$key} .= ", ".$value;
  55.       }else{
  56.          ${$key} = $value;
  57.       }
  58.    }
  59. }  
  60.  
  61. FUNCTION:   doFormError
  62.  
  63.  sub doFormError {
  64.     my ($errString) = @_;
  65.  
  66.     open (HEAD, $header);
  67.     @LINES = <HEAD>;
  68.     close HEAD;
  69.  
  70.     print "Content-type: text/html\n\n";
  71.  
  72.     print @LINES;
  73.  
  74.     print "<FONT SIZE=+2>The form you submitted was not complete.<BR><BR></FONT>";
  75.     print "$errString<BR><BR>\n";
  76.     print "<INPUT TYPE=BUTTON ONCLICK='history.back()' VALUE='  Return to the checkout page '><HR>";
  77.  
  78.     open (FOOT, $footer);
  79.     @LINES = <FOOT>;
  80.     close FOOT;
  81.     print @LINES;
  82.  
  83.     exit;
  84. }
  85.  
  86. #FUNCTION:   doError
  87.  
  88. ub doError {
  89.     my ($errString) = @_;
  90.     print "Content-type: text/html\n\n";
  91.  
  92.     open (HEAD, $header);
  93.     @LINES = <HEAD>;
  94.     close HEAD;
  95.  
  96.     print @LINES;
  97.  
  98.     print "$errString<BR><BR>\n";
  99.  
  100.     open (FOOT, $footer);
  101.     @LINES = <FOOT>;
  102.     close FOOT;
  103.     print @LINES;
  104.  
  105.     exit;
  106. }
  107.  
  108.  
  109. FUNCTION:   invalidE
  110.  
  111. sub invalidE {
  112.   my ($szEmail) = @_;
  113.   my ($user, $host);
  114.  
  115.   $szEmail =~ tr/A-Z/a-z/;
  116.   if ($szEmail =~ /\s/) { return 1; }
  117.   ($user, $host) = split (/\@/, $szEmail);
  118.   if ($host =~ /compuserve/i) { ; }
  119.   else {
  120.     if (! $user =~ /\D/) { return 1; }
  121.     if (! $host =~ /\D/) { return 1; }
  122.     if (substr ($user,0,1) !~ /[a-z]/) { return 1; }
  123.   }
  124.   if ($szEmail =~ /\w+\@[\w|\.]/) { return 0; }
  125.   else { return 1; }
  126. }
  127.  
  128.  
  129. sub populateDateVar {
  130.    @months = ();
  131.    push(@months,"January");
  132.    push(@months,"February");
  133.    push(@months,"March");
  134.    push(@months,"April");
  135.    push(@months,"May");
  136.    push(@months,"June");
  137.    push(@months,"July");
  138.    push(@months,"August");
  139.    push(@months,"September");
  140.    push(@months,"October");
  141.    push(@months,"November");
  142.    push(@months,"December");
  143.    @days = ();
  144.    push(@days,"Sunday");
  145.    push(@days,"Monday");
  146.    push(@days,"Tuesday");
  147.    push(@days,"Wednesday");
  148.    push(@days,"Thursday");
  149.    push(@days,"Friday");
  150.    push(@days,"Saturday");
  151.    ($sec,$min,$hour,$day,$month,$year,$day2) =
  152.    (localtime(time))[0,1,2,3,4,5,6];
  153.    if ($sec < 10) { $sec = "0$sec"; }
  154.    if ($min < 10) { $min = "0$min"; }
  155.    if ($hour < 10) { $hour = "0$hour"; }
  156.    if ($day < 10) { $day = "0$day"; }
  157.    $year += "1900";
  158.  
  159.    #$todaysdate = "$months[$month] $day, $year $hour:$min:$sec";
  160. }
  161.  
  162. MAIN    
  163.  
  164. # process the form input.
  165. &processCGI;
  166. &populateDateVar;
  167.  
  168. foreach $check(@required) {
  169.    unless ($check) {
  170.       doFormError("It appears that you forgot to fill in the <strong>$check</strong> field.");
  171.       exit;
  172.    }
  173. }
  174.  
  175. # checks for valid email address
  176. if( &invalidE($b_email) ){
  177.    doFormError('You submitted an invalid email address.');
  178. }