Foros del Web » Programando para Internet » PHP »

superar limitacion de destinatarios por medio de bucle

Estas en el tema de superar limitacion de destinatarios por medio de bucle en el foro de PHP en Foros del Web. Hola a todos. Tengo actualmente el siguiente codigo: ------------------------------------------------------- <?php $texto = $_POST['texto']; $edu = $_POST['edu']; if ($_POST['asignatura']=="") { $asunto="[RICHMOND] ".$_POST["asunto"]; } else { $asunto="[RICHMOND]".$_POST["asignatura"]." ...
  #1 (permalink)  
Antiguo 24/11/2009, 16:00
 
Fecha de Ingreso: mayo-2009
Mensajes: 43
Antigüedad: 14 años, 11 meses
Puntos: 2
superar limitacion de destinatarios por medio de bucle

Hola a todos. Tengo actualmente el siguiente codigo:
-------------------------------------------------------

<?php
$texto = $_POST['texto'];
$edu = $_POST['edu'];
if ($_POST['asignatura']=="") {
$asunto="[RICHMOND] ".$_POST["asunto"];
}
else {
$asunto="[RICHMOND]".$_POST["asignatura"]." - ".$_POST["asunto"];
}
$sender = $_POST['sender'];
$informacion = $_POST['informacion'];
require("class.phpmailer.php");
$mail = new PHPMailer();
$mail->IsSMTP();
$mail->SMTPAuth = true; // enable SMTP authentication
$mail->SMTPSecure = "ssl"; // sets the prefix to the servier
$mail->Host = "*******"; // sets GMAIL as the SMTP server
$mail->Port = 465; // set the SMTP port for the GMAIL server
$mail->IsHTML(true);
$mail->Username = "******"; // GMAIL username
$mail->Password = "******"; // GMAIL password
$mail->From = $_POST['sender'];
$mail->FromName = $_POST['nombre'];
$mail->Sender = $_POST['sender'];
$mail->Subject = $asunto;
$mail->Body = "<table border='0' cellpadding='0' bordercolor='black' style='border-collapse: collapse'>
<tr>
<td height='51' width='16' bgcolor='black' style='border-left-style: solid; border-left-width: 1px; border-right-style: none; border-right-width: medium; border-top-style: solid; border-top-width: 1px; border-bottom-style: solid; border-bottom-width: 1px' rowspan='2'>&nbsp;</td>
<td bgcolor='red' style='border-left-style: none; border-left-width: medium; border-right-style: solid; border-right-width: 1px; border-top-style: solid; border-top-width: 1px; border-bottom-style: solid; border-bottom-width: 1px'>
<p align='center'><b><span style='background-color: 'red'>
<font size='2' color='black'>- RICHMOND MAIL -</font></span></b></p></td>
</tr>
<tr>
<td bgcolor='red' style='border-left-style: none; border-left-width: medium; border-right-style: solid; border-right-width: 1px; border-top-style: solid; border-top-width: 1px; border-bottom-style: solid; border-bottom-width: 1px'>
<p align='center'>
<span style='font-weight: 700; background-color: 'red'>
<font size='2' color='black'>COMUNICACIONES PROFESORADO - E.U.A. RELACIONES LABORALES,
TRABAJO SOCIAL Y TURISMO</font></span></p></td>
</tr>
<tr>
<td height='16' width='16' style='border-left-style: none; border-left-width: medium; border-right-style: none; border-right-width: medium'>&nbsp;</td>
<td height='9' width='763' style='border-left-style: none; border-left-width: medium; border-bottom-style: solid; border-bottom-width: 1px'>
</td>
</tr>
<tr>
<td height='16' width='16' bgcolor='red' style='border-left-style: solid; border-left-width: 1px; border-right-style: none; border-right-width: medium; border-top-style: solid; border-top-width: 1px; border-bottom-style: none; border-bottom-width: medium'>&nbsp;</td>
<td height='16' width='763' bgcolor='red' style='border-left-style: none; border-left-width: medium; border-right-style: none; border-right-width: medium; border-top-style: solid; border-top-width: 1px'>&nbsp;</td>
</tr>
<tr>
<td height='16' width='16' bgcolor='red' style='border-left-style: solid; border-left-width: 1px; border-right-style: none; border-right-width: medium; border-top-style: none; border-top-width: medium; border-bottom-style: none; border-bottom-width: medium'>&nbsp;</td>
<td height='343' width='763' style='border-left-style: none; border-left-width: medium' valign='top'>
<font color='blue'>$texto</font></td>
</tr>
</table>";
$mail->WordWrap = 500;
$path = $_FILES['archivo']['tmp_name'];
$nombre = $_FILES['archivo']['name'];
$tipo_archivo = $_FILES['archivo']['type'];
$tamano_archivo = $_FILES['archivo']['size'];
$mail->AddAttachment($path,$nombre,"base64",$tipo_archiv o);
$path2 = $_FILES['archivo2']['tmp_name'];
$nombre2 = $_FILES['archivo2']['name'];
$tipo_archivo2 = $_FILES['archivo2']['type'];
$tamano_archivo = $_FILES['archivo2']['size'];
$mail->AddAttachment($path2,$nombre2,"base64",$tipo_arch ivo2);
if ($_POST['trabajo1']=="ON") {
$mail->addBCC("direccionpersonal[arroba]dominio.com");
}
if ($_POST['trabajo2']=="ON") {
$mail->addBCC("direccionpersonal[arroba]dominio.com");
}
if ($_POST['trabajo3']=="ON") {
$mail->addBCC("direccionpersonal[arroba]dominio.com");
}
if ($_POST['trabajotarde1']=="ON") {
$archivo = file("1TST.txt");
$lineas = count($archivo);
for($i=0; $i < $lineas; $i++)
{
$mail->addBCC("$archivo[$i]");
}
}
if ($_POST['trabajotarde2']=="ON") {
$archivo = file("2TST.txt");
$lineas = count($archivo);
for($i=0; $i < $lineas; $i++)
{
$mail->addBCC("$archivo[$i]");
}
}
if ($_POST['trabajotarde3']=="ON") {
$archivo = file("3TST.txt");
$lineas = count($archivo);
for($i=0; $i < $lineas; $i++)
{
$mail->addBCC("$archivo[$i]");
}
}
if ($_POST['relaciones1']=="ON") {
$archivo = file("1RL.txt");
$lineas = count($archivo);
for($i=0; $i < $lineas; $i++)
{
$mail->addBCC("$archivo[$i]");
}
}
if ($_POST['relaciones2']=="ON") {
$archivo = file("2RL.txt");
$lineas = count($archivo);
for($i=0; $i < $lineas; $i++)
{
$mail->addBCC("$archivo[$i]");
}
}
if ($_POST['relaciones3']=="ON") {
$archivo = file("3RL.txt");
$lineas = count($archivo);
for($i=0; $i < $lineas; $i++)
{
$mail->addBCC("$archivo[$i]");
}
}
if ($_POST['turismo2']=="ON") {
$archivo = file("2TU.txt");
$lineas = count($archivo);
for($i=0; $i < $lineas; $i++)
{
$mail->addBCC("$archivo[$i]");
}
}
if ($_POST['turismo3']=="ON") {
$archivo = file("3TU.txt");
$lineas = count($archivo);
for($i=0; $i < $lineas; $i++)
{
$mail->addBCC("$archivo[$i]");
}
}
if(!$mail->Send()){
echo "Mailer Error: " . $mail->ErrorInfo;
}else{
echo "Su mensaje ha sido enviado...";
}
?>

-----------------------------------------------------------
Como podéis ver con las tres primeras casillas de destinatarios me he visto obligado a poner una dirección personal para reenviarselo al resto, la razón es que mi servidor me impone una limitacion de 125 destinatarios por mensaje, ¿hay alguna manera de implementar un bucle o alguna otra solución en ese codigo? Por mas que lo intento no lo consigo. Gracias a todos.
  #2 (permalink)  
Antiguo 24/11/2009, 16:14
Avatar de _-ZeuS-_  
Fecha de Ingreso: junio-2007
Ubicación: Quito, Ecuador! ;)
Mensajes: 100
Antigüedad: 16 años, 10 meses
Puntos: 7
Respuesta: superar limitacion de destinatarios por medio de bucle

tal vez si pones un intervalo de tiempo entre cada envío es decir antes de $mail->Send() podrías poner algo como sleep(120); el número ke va en medio es el total de segundos ke kieres esperar
  #3 (permalink)  
Antiguo 25/11/2009, 08:06
 
Fecha de Ingreso: mayo-2009
Mensajes: 43
Antigüedad: 14 años, 11 meses
Puntos: 2
Respuesta: superar limitacion de destinatarios por medio de bucle

La solucion seria contar cuantos destinatarios van y mandar 125, despues otros 125 y por ultimo los 50 restantes, el problema es que no se como hacerlo, deberia meter los destinatarios en un array cada uno de los if y despues contarlos y enviarlos de 125 en 125, ha esta conclusión he llegado gracias a zeus
Atención: Estás leyendo un tema que no tiene actividad desde hace más de 6 MESES, te recomendamos abrir un Nuevo tema en lugar de responder al actual.
Respuesta




La zona horaria es GMT -6. Ahora son las 14:39.