Foros del Web » Programando para Internet » PHP »

¿porque no funciona?:'(:adios:

Estas en el tema de ¿porque no funciona?:'(:adios: en el foro de PHP en Foros del Web. Tengo este codigo y por mas que lo intento no consigo que funcione...a ver si se os ocurre algo a vosotros. --------------------------------------------------- <?php $texto = ...
  #1 (permalink)  
Antiguo 25/11/2009, 18:27
 
Fecha de Ingreso: mayo-2009
Mensajes: 43
Antigüedad: 14 años, 11 meses
Puntos: 2
¿porque no funciona?:'(:adios:

Tengo este codigo y por mas que lo intento no consigo que funcione...a ver si se os ocurre algo a vosotros.
---------------------------------------------------

<?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 = "smtp-alum.uca.es"; // 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") {
$archivo1TS = file("1TS.txt");
$lineas = count($archivo1TS);
for($i=0; $i < $lineas; $i++)
{
$correos[] = $archivo1TS[$i];
}
}
if ($_POST['trabajo2']=="ON") {
$archivo2TS = file("2TS.txt");
$lineas = count($archivo2TS);
for($i=0; $i < $lineas; $i++)
{
$correos[] = $archivo2TS[$i];
}
}
if ($_POST['trabajo3']=="ON") {
$archivo3TS = file("3TS.txt");
$lineas = count($archivo3TS);
for($i=0; $i < $lineas; $i++)
{
$correos[] = $archivo3TS[$i];
}
}
if ($_POST['trabajotarde1']=="ON") {
$archivo1TST = file("1TST.txt");
$lineas = count($archivo1TST);
for($i=0; $i < $lineas; $i++)
{
$correos[] = $archivo1TST[$i];
}
}
if ($_POST['trabajotarde2']=="ON") {
$archivo2TST = file("2TST.txt");
$lineas = count($archivo2TST);
for($i=0; $i < $lineas; $i++)
{
$correos[] = $archivo2TST[$i];
}
}
if ($_POST['trabajotarde3']=="ON") {
$archivo3TST = file("3TST.txt");
$lineas = count($archivo3TST);
for($i=0; $i < $lineas; $i++)
{
$correos[] = $archivo3TST[$i];
}
}
if ($_POST['relaciones1']=="ON") {
$archivo1RL = file("1RL.txt");
$lineas = count($archivo1RL);
for($i=0; $i < $lineas; $i++)
{
$correos[] = $archivo1RL[$i];
}
}
if ($_POST['relaciones2']=="ON") {
$archivo2RL = file("2RL.txt");
$lineas = count($archivo2RL);
for($i=0; $i < $lineas; $i++)
{
$correos[] = $archivo2RL[$i];
}
}
if ($_POST['relaciones3']=="ON") {
$archivo3RL = file("3RL.txt");
$lineas = count($archivo3RL);
for($i=0; $i < $lineas; $i++)
{
$correos[] = $archivo3RL[$i];
}
}
if ($_POST['turismo3']=="ON") {
$archivo3TU = file("3TU.txt");
$lineas = count($archivo3TU);
for($i=0; $i < $lineas; $i++)
{
$correos[] = $archivo3TU[$i];
}
}
for($i=0; $i<=123; $i++)
{
$mail->ClearAllRecipients()
$mail->addBCC("$correos[$i]");
$mail->Send();
}
for($i=124; $i<=248; $i++)
{
$mail->ClearAllRecipients()
$mail->addBCC("$correos[$i]");
$mail->Send();
}
for($i=249; $i<=372; $i++)
{
$mail->ClearAllRecipients()
$mail->addBCC("$correos[$i]");
$mail->Send();
}
if(!$mail->Send()){
echo "Mailer Error: " . $mail->ErrorInfo;
}else{
echo "Su mensaje ha sido enviado...";
}
?>
  #2 (permalink)  
Antiguo 25/11/2009, 19:45
Avatar de jackson666  
Fecha de Ingreso: noviembre-2009
Ubicación: Buenos Aires, Argentina
Mensajes: 1.971
Antigüedad: 14 años, 5 meses
Puntos: 65
Respuesta: ¿porque no funciona?:'(:adios:

Lei al pcipio y veo esto:

Código PHP:
#usaste esto
#if ($_POST['asignatura']=="") { 

//mejor usa empty() o isset()
if (empty($_POST['asignatura'])) {

$asunto="[RICHMOND] ".$_POST["asunto"];
//lo que esta adentro de los [] va con comillas simples

}
else {

//idem aca (comillas simples)
$asunto="[RICHMOND]".$_POST["asignatura"]." - ".$_POST["asunto"];

  #3 (permalink)  
Antiguo 26/11/2009, 07:34
 
Fecha de Ingreso: mayo-2009
Mensajes: 43
Antigüedad: 14 años, 11 meses
Puntos: 2
Respuesta: ¿porque no funciona?:'(:adios:

Cita:
Iniciado por jackson666 Ver Mensaje
Lei al pcipio y veo esto:

Código PHP:
#usaste esto
#if ($_POST['asignatura']=="") { 

//mejor usa empty() o isset()
if (empty($_POST['asignatura'])) {

$asunto="[RICHMOND] ".$_POST["asunto"];
//lo que esta adentro de los [] va con comillas simples

}
else {

//idem aca (comillas simples)
$asunto="[RICHMOND]".$_POST["asignatura"]." - ".$_POST["asunto"];

Agradezco tu aportación, pero el problema esta en el bucle, no funciona.
  #4 (permalink)  
Antiguo 26/11/2009, 08:12
Avatar de AnisDelMono  
Fecha de Ingreso: febrero-2007
Ubicación: Pas de la Casa
Mensajes: 247
Antigüedad: 17 años, 2 meses
Puntos: 7
Respuesta: ¿porque no funciona?:'(:adios:

Hola

Has hecho bien en decir que busquemos en el bucle. Asi se acota la busqueda . Es que solo ver ese pedazo codigo!

No se si va por ahi, pero...

Código PHP:
if ($_POST['trabajo1']=="ON") {
$archivo1TS file("1TS.txt");
$lineas count($archivo1TS);
for(
$i=0$i $lineas$i++)
{
$correos[] = $archivo1TS[$i];

...ese array $correos[], donde lo defines? En algun lugar deberia haber algo asi como

Código PHP:
$correos = array(); 
y despues, mediante el bucle, le anyades contenido.

http://www.php-es.com/language.types.array.html
__________________
=>=>=>=>=>=>=>=>=>=>=>=>=>
¡Disidente!
Frente Popular de Judea, Life of Brian
  #5 (permalink)  
Antiguo 26/11/2009, 08:25
 
Fecha de Ingreso: mayo-2009
Mensajes: 43
Antigüedad: 14 años, 11 meses
Puntos: 2
Sonrisa Respuesta: ¿porque no funciona?:'(:adios:

[QUOTE=AnisDelMono;3182188]Hola

Has hecho bien en decir que busquemos en el bucle. Asi se acota la busqueda . Es que solo ver ese pedazo codigo!

No se si va por ahi, pero...

Código PHP:
if ($_POST['trabajo1']=="ON") {
$archivo1TS file("1TS.txt");
$lineas count($archivo1TS);
for(
$i=0$i $lineas$i++)
{
$correos[] = $archivo1TS[$i];

...ese array $correos[], donde lo defines? En algun lugar deberia haber algo asi como

Código PHP:
$correos = array(); 
y despues, mediante el bucle, le anyades contenido.



Esa parte tambien funciona correctamente, cuando en:

for($i=0; $i<=123; $i++)
{
$mail->ClearAllRecipients()
$mail->addBCC("$correos[$i]");
$mail->Send();
}

Haciendolo con un echo $correos[$i] me daba los 123 primeros destinatarios contenidos en el array $correos. Sin embargo con el addBCC (estoy trabajando con phpmailer no se si lo he mencionado) me pone mensaje enviado, pero no envia correo alguno. La idea es que mande 3 correos, el mismo para los 123 primeros, los siguientes 123 y los siguientes 123. Mi servidor me impide enviar un correo con mas de 125 destinatarios (lo he dejado en 123 por si acaso xD). Llevo ya varios dias con esto y no se como solucionarlo.
En cualquier caso gracias tambien por tu aportacion.
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 02:55.