Ver Mensaje Individual
  #3 (permalink)  
Antiguo 09/05/2013, 12:01
alex1084
 
Fecha de Ingreso: abril-2008
Ubicación: El Salvador
Mensajes: 736
Antigüedad: 15 años, 11 meses
Puntos: 47
Respuesta: phpmailer no envia doc adjunto

Creo que asi talvez te funcione


Código PHP:
Ver original
  1. <?php
  2. require("../phpmailer/class.phpmailer.php");
  3. if(isset($_POST['asunto'])){  
  4.     $varname = $_FILES['archivo']['name'];  //*
  5.     $vartemp = $_FILES['archivo']['tmp_name'];  //*
  6.     $mail = new PHPMailer();  
  7.     $mail->Host = "localhost";  
  8.     $mail->From = "[email protected]";  
  9.     $mail->FromName = "Plantel";  
  10.     $mail->Subject = $_POST['asunto'];  
  11.     //*
  12.  
  13.      //*
  14.     if(!empty($_POST['email'])) {  
  15.         $aLista=$_POST['email'];
  16.          
  17.         mysql_select_db($database_connection, $connection);  
  18.         $result= "SELECT * FROM informesp where Folio IN (".implode(',',$aLista).")";    
  19.         $rs1= mysql_query($result, $connection) or die(mysql_error());  
  20.         if(mysql_num_rows($rs1)>0){          
  21.             while ($row = mysql_fetch_array($rs1)){  
  22.                 // HTML body    
  23.                 $body = "Hola <strong>".$row["Nombre"]."</strong>, ";    
  24.                 $body.= $_POST[mensaje];    
  25.                  
  26.                 // Text body  
  27.                 $text = "Hola ".$row["Nombre"].", \n\n";    
  28.                 $text.= $_POST[mensaje];  
  29.                
  30.                 // Configurar Email  
  31.                 $mail->Body = $body;    
  32.                 $mail->AltBody = $text;    
  33.                 $mail->AddAddress($row["Email"], $row["Nombre"]);  
  34.                 //*
  35.                 if ($varname != "")  
  36.                 {
  37.                 $mail->AddAttachment($vartemp, $varname);
  38.                  }
  39.                 //*
  40.                 // Enviar el email  
  41.                 if(!$mail->Send()) {  
  42.                     echo "Error al enviar a: " . $row["Email"] . "<br>";    
  43.                 }  
  44.                 else {
  45.               echo "<script language='JavaScript'>  
  46.                alert('Mensaje Enviado');
  47.                </script>";
  48.                  }
  49.                 $mail->ClearAddresses();    
  50.             }                
  51.         }  
  52.     }  
  53. }  
  54. ?>