Ver Mensaje Individual
  #1 (permalink)  
Antiguo 09/05/2013, 11:56
Avatar de Briss
Briss
 
Fecha de Ingreso: junio-2011
Mensajes: 1.293
Antigüedad: 12 años, 10 meses
Puntos: 12
Exclamación phpmailer no envia doc adjunto

Hola!!!!Tengo el siguiente archivo el cual me sirve para enviar emails multiples funciona bien solo que no encuentro porque no se envia el archivo adjunto
ya trabaje antes con este codigo en un envio unico y funciono solo que aqui por el while y demás no sé si meti las lineas donde debe ser xD
alguien puede ayudarme por favor
mi file viene de un form y el nombre si es correcto archivo
Código PHP:
require("../phpmailer/class.phpmailer.php");

if(isset(
$_POST['asunto'])){ 
    
$varname $_FILES['archivo']['name'];  //*
    
$vartemp $_FILES['archivo']['tmp_name'];  //*
    
$mail = new PHPMailer();  
    
$mail->Host "localhost";  
    
$mail->From "[email protected]";  
    
$mail->FromName "Plantel";  
    
$mail->Subject $_POST['asunto']; 
    
//*
    
if ($varname != ""
    {
    
$mail->AddAttachment($vartemp$varname);
     } 
     
//*
    
if(!empty($_POST['email'])) {  
        
$aLista=$_POST['email'];
        
        
mysql_select_db($database_connection$connection);  
        
$result"SELECT * FROM informesp where Folio IN (".implode(',',$aLista).")";    
        
$rs1mysql_query($result$connection) or die(mysql_error());  
        if(
mysql_num_rows($rs1)>0){         
            while (
$row mysql_fetch_array($rs1)){ 
                
// HTML body   
                
$body "Hola <strong>".$row["Nombre"]."</strong>, ";   
                
$body.= $_POST[mensaje];   
                
                
// Text body  
                
$text "Hola ".$row["Nombre"].", \n\n";   
                
$text.= $_POST[mensaje];  
               
                
// Configurar Email  
                
$mail->Body $body;   
                
$mail->AltBody $text;   
                
$mail->AddAddress($row["Email"], $row["Nombre"]);  
                
//*
                
if(!empty( $file_name )) { 
                
$mail->AddAttachment($_FILES["archivo"]["tmp_name"], $_FILES["archivo"]["name"]); 
                } 
                
//*
                // Enviar el email  
                
if(!$mail->Send()) {  
                    echo 
"Error al enviar a: " $row["Email"] . "<br>";   
                }  
                else {
              echo 
"<script language='JavaScript'> 
                alert('Mensaje Enviado');
                </script>"
;
                 }
                
$mail->ClearAddresses();    
            }                
        }  
    }