Ver Mensaje Individual
  #1 (permalink)  
Antiguo 07/05/2013, 16:27
Avatar de Briss
Briss
 
Fecha de Ingreso: junio-2011
Mensajes: 1.293
Antigüedad: 12 años, 10 meses
Puntos: 12
Error con phpmailer correo masivo

Hola tengo el siguiente archivo q funciona basicamente asi tengo un form donde voy a redactar asunto, email, mensaje (para enviar un email multiple)
en el input email capturo todas las direcciones de correo que han sido seleccionadas previamente mediante un check
ya hice la prueba individual y sale el problema lo obtengo aca porque trabajo con arrays alguien me puede ayudar no encuentro el error :/



Código PHP:
require_once('../Connections/connection.php'); 
require(
"../phpmailer/class.phpmailer.php");
if (
$_POST['action'] == "send") {
    
$varname $_FILES['archivo']['name'];
    
$vartemp $_FILES['archivo']['tmp_name'];
     
     
$mail = new PHPMailer();
$mail->Host "localhost";

     
$email $_POST[email2];
    
$mensaje.= $_POST['mensaje']."\n\n";
    
    
// asunto del email
    
$subject $_POST[asunto];
$mail->From $_POST[email2];
 if (
$varname != "") {
        
$mail->AddAttachment($vartemp$varname);
    }
$mail->FromName "Plantel";
$mail->Subject $_POST['asunto'];
$emails $_POST[email];
foreach (
$emails as $email) {
     
$mail->AddAddress($email);
}

//$mail->AddAddress($address, "Probando");
$body .= $mensaje;
$mail->Body $body;
if(!empty( 
$file_name )) { 
$mail->AddAttachment($_FILES["archivo"]["tmp_name"], $_FILES["archivo"]["name"]);  } 
if(!
$mail->Send()) {
  echo 
"Mailer Error: " $mail->ErrorInfo;
} else {
  echo 
"¡Mensaje Enviado!";
}
}


if(!empty(
$_POST['email'])) {  
$aLista=$_POST['email'];  
mysql_select_db($database_connection$connection);
$sql.= "SELECT * FROM informesp where Folio IN (".implode(',',$aLista).")";  
$rsmysql_query($sql$connection) or die(mysql_error());
if(
mysql_num_rows($rs)>0)  
{    
  
    while(
$row mysql_fetch_assoc($rs)) 
    { 
 echo 
'<form action="" method="post" enctype="multipart/form-data">';
  


  
$Folio $Folio.$row["Email"].",";
          
          } 
        
$Folio substr($Folio0strlen($Folio)-1);
   
    echo 
'<input type="text" name="email[]"   value="'.$Folio.'"  />';





     



      echo 
' <tr valign="middle">';
       echo 
' <td height="45" ><div align="left"><font size="2">Asunto:</font></div></td>';
        echo 
'  <td height="45"><input type="text" name="asunto"   value=""  /></td>';
      echo 
'  </tr>';
      
      
      echo 
' <tr valign="middle">';
        echo 
' <td height="45" ><div align="left"><font size="2">Adjuntar archivo:</font></div></td>';
        echo 
'<input type="file" size="25" id="caja" name="archivo" style="width:400px"/>';
       echo 
'  </tr>';
        echo 
'<input type="text" name="email2"   value=""  />';
        
     echo 
' <tr valign="middle">';
       echo 
' <td height="45" ><div align="left"><font size="2">Mensaje:</font></div></td>';
        echo 
'  <td height="45"><textarea name="mensaje" cols="32"  ></textarea></td>';
      echo 
'  </tr>';
    echo 
'  <tr valign="baseline">';
  echo 
'  <td><input type="submit" value="Cancelar " /></td>';
      echo 
'  <td> <input type="image" name="btsend" src="img/CorreoE3Bn_r12_c9.png" border="0" id="btsend" alt="" /></td>';
   echo 
'   </tr>';
   echo 
'   </table>';
 
  echo 
'  <input type="hidden" name="action" value="send" />';
  echo 
'</form>';

 


?>