Problema al mandar mails a hotmail

Status
Not open for further replies.

cetutnx1

New Member
Messages
510
Reaction score
0
Points
0
Hola, en realidad este no es un "problema del servidor", pero necesitaría ayuda.
He creado un newsletter, pero el correo enviado a hotmail llega perfecto, pero con el contenido vacío.
Les dejo el código si alguien tiene una solución por favor la estoy necesitando hace más de 2 semanas que este script me tiene un poco arto...
Aquí está, está alojado en este hosting:

PHP:
<?php
ERROR_REPORTING(E_ALL);
define('ACCESS',true);
require("../includes/config.inc.php");
require("admin.inc.php");
?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
 <head>
  <title>Sistema de Administracion de Newsletter</title>
  <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
  <meta name="autor" content="Gonzalo García" />
  <link href="style.css" rel="stylesheet" type="text/css" />
  <script type="text/javascript">
    _editor_url  = "../editor/"  // (preferably absolute) URL (including trailing slash) where Xinha is installed
    _editor_lang = "es";      // And the language we need to use in the editor.
  </script>
  <script type="text/javascript" src="../editor/htmlarea.js"></script>
  <script type="text/javascript" src="../editor/config.js"></script>
 </head>
 <body class="content">
  <h1>Enviar Correo</h1>
  <div id="todo">
<?php
$step = $_GET['step'];

if(!isset($step)) {
    $list = $_GET['list'];
?>
   <form id="editors_here" method="post" enctype="multipart/form-data" action="sendmail.php?step=2">
    <table>
     <tbody>
      <tr>
       <td style="text-align: left;"><label for="para" title="Para:">Para: </label></td>
       <td>
        <select name="para" id="para" style="width: 350px;">
         <option value=""<?php if ($list == "") {printf(" selected=\"selected\"");} ?>> - Seleccione Una Carrera - </option>
         <option value="civil"<?php if ($list == "civil") {printf(" selected=\"selected\"");} ?>>Ing. Civil</option>
         <option value="electrica"<?php if ($list == "electrica") {printf(" selected=\"selected\"");} ?>>Ing. Eléctrica</option>
         <option value="electronica"<?php if ($list == "electronica") {printf(" selected=\"selected\"");} ?>>Ing. Electrónica</option>
         <option value="industrial"<?php if ($list == "industrial") {printf(" selected=\"selected\"");} ?>>Ing. Industrial</option>
         <option value="mecanica"<?php if ($list == "mecanica") {printf(" selected=\"selected\"");} ?>>Ing. Mecánica</option>
         <option value="metalurgica"<?php if ($list == "metalurgica") {printf(" selected=\"selected\"");} ?>>Ing. Metalúrgica</option>
         <option value="quimica"<?php if ($list == "quimica") {printf(" selected=\"selected\"");} ?>>Ing. Química</option>
         <option value="sistema"<?php if ($list == "sistema") {printf(" selected=\"selected\"");} ?>>Ing. Sistemas</option>
         <option value="ingresante"<?php if ($list == "ingresante") {printf(" selected=\"selected\"");} ?>>Ingresantes</option>
         <option value="todos"<?php if ($list == "all") {printf(" selected=\"selected\"");} ?>>Todos</option>
        </select>
       </td>
      </tr>
      <tr>
       <td style="text-align: left;"><label for="asunto" title="Asunto:">Asunto: </label></td>
       <td><input type="text" name="asunto" id="asunto" style="width: 350px;" /></td>
      </tr>
      <tr>
       <td>
        Adjuntar Archivo:
       </td>
       <td>
        <input type="file" name="adjunto" id="adjunto" />
       </td>
      </tr>
      <tr>
       <td colspan="2">
        <label title="Cuerpo del mensaje">
         <textarea name="mensaje" id="mensaje" style="width: 100%; height: 320px;"></textarea>
        </label>
       </td>
      </tr>
      <tr>
       <td colspan="2">
        <input type="submit" value="Enviar Correo" />
       </td>
      </tr>
     </tbody>
    </table>
   </form>
<?php
}
elseif($step == 2) {
    
    //Averiguo para quien es el mail...
    $para = $_POST['para'];
    $asunto = $_POST['asunto'];
    $adjunto = $_FILES['adjunto'];
    $contenido = $_POST['mensaje'];
    $contenido = stripslashes($contenido);
    $contenido_plano = strip_tags($contenido);
    $bid = "----------=_".time(); //Identificador único de boundary(no se que es pero igual lo pongo)
    $boundary = "boundary=\"".$bid."\"";

    //Aquí estan las cabeceras del mensaje
    $cabeceras = "From: ".$config['from']."\r\n";
    $cabeceras .= "Reply-To: ".$config['reply']."\r\n";
    $cabeceras .= "Return-path: ".$config['reply']."$\r\n"
    $cabeceras .= "Message-ID: <cet-utn@".$_SERVER['SERVER_NAME'].">\r\n"
    $cabeceras .= "X-Mailer: PHP/".phpversion()."\r\n";
    $cabeceras .= "Date: ".$mail['fecha']."\r\n";
    $cabeceras .= "MIME-Version: 1.0\r\n";
    
    if($adjunto['size'] != 0) {
        $cabeceras .= "Content-Type: multipart/mixed;".$boundary."\r\n\r\n";
        $cabeceras .= "\r\nThis is a multi-part message in MIME format.\r\n\r\n";
        $fd = fopen($adjunto['tmp_name'], "r");
        $contents = fread($fd, filesize($adjunto['tmp_name']));
        $encoded = chunk_split(base64_encode($contents));
        fclose($fd);
        $mensaje .= "Content-Type: application/octet-stream; name=\"".$adjunto['name']."\"\r\n";
        $mensaje .= "Content-Transfer-Encoding: base64\r\n";
        $mensaje .= "Content-Disposition: attachment; filename=\"".$adjunto['name']."\"\r\n";
        $mensaje .= $encoded;
        $mensaje .= "\r\n--".$bid."\r\n";
    }
    else {
        $cabeceras .= "Content-Type: multipart/alternative;".$boundary."\r\n\r\n";
        $cabeceras .= "\r\nThis is a multi-part message in MIME format.\r\n\r\n";

    }
    
    
    $mensaje = "--$bid\r\n";

    //Mensaje en texto plano
    $mensaje .= "Content-Type: text/plain; charset=\"iso-8859-1\"\r\n";
    $mensaje .= "Content-Transfer-Encoding: 7bit\r\n";
    $mensaje .= "\r\n".$contenido_plano."\r\n";

    //Mensaje en html
    $mensaje .= "--$bid\r\n";
    $mensaje .= "Content-Type: text/html; charset=\"iso-8859-1\"\r\n";
    $mensaje .= "Content-Transfer-Encoding: 7bit\r\n\r\n";
    $mensaje .= "<html>\n <body>\n";
    $mensaje .= $contenido;
    $mensaje .= " </body>\n</html>\n";
    $mensaje .= "\r\n--".$bid."\r\n";
    
    //La función mail de php no permite mandar
    //lineas que sean más largas que 70 caracteres
    $mensaje = wordwrap($mensaje, 70);
    
//    save_mail($para,$asunto,$mensaje,$cabeceras);

    printf($cabeceras);
    printf($mensaje);
    if($para != "todos" && $para != "") {
        $location = $listdir;
        $prefix = $config['file']."_";
        $file = $location.$prefix.$para.".csv";
        
        //Abro el archivo de contectos
        $newfile = fopen($file,"r");
        $content = fread($newfile, filesize($file));
        
        //Separo los emails
        $lines = explode("\n",$content);
        fclose($newfile);
        $sended = 0;
        $nosended = 0;
        $who_yes = "";
        $who_no = "";
/*        foreach($lines as $l) {
            $l = trim("$l");
            $l = strtolower("$l");
            if($l != "dirección de correo electrónico" && $l != "") {*/
            $l = "ggarcia_24@hotmail.com, ggarcia_24@argentina.com, ema056@yahoo.com.ar, ealtamira@sae.frc.utn.edu.ar,50835@electronica.frc.utn.edu.ar";
                if(mail($l, $asunto, $mensaje, $cabeceras)) {
                    $sended++;
                    $who_yes .= $l."<br />\n";
                }
                else {
                    $nosended++;
                    $who_no .= $l."<br />\n";
                }
            /*}
        }*/
    }
    elseif ($para == "todos") {
        $location = $listdir;
        $prefix = $config['file']."_";
        $file = $location.$prefix."all.csv";
        
        //Abro el archivo
        $newfile = fopen($file,"r");
        $content = fread($newfile, filesize($file));
        
        //Separo nombre, apellidos, y email
        $lines = explode("\n",$content);
        fclose($newfile);
        foreach($lines as $l) {
            $l = trim("$l");
            $l = strtolower("$l");
            if($l != "dirección de correo electrónico" && $l != "") {
                if(mail($l, $asunto, $mensaje, $cabeceras)) {
                    $sended++;
                    $who_yes .= $l."<br />\n";
                }
                else {
                    $nosended++;
                    $who_no .= $l."<br />\n";
                }
            }
        }
    }
    printf("Se han enviado correctamente $sended emails<br />");
    printf("No se han enviado correctamente $nosended emails <br />");
    printf("A: <br />$who_no");
}
?>
  </div>
 </body>
</html>
 

c4ngry

Member
Messages
34
Reaction score
0
Points
6
man te recomiendo uses otro tipo de Pop por q no intentas con Gmail es mejor y mas facil..
 

cetutnx1

New Member
Messages
510
Reaction score
0
Points
0
c4ngry no entiendo que es lo que inentas decirme pero gracias por responder.
Ya he resuelto este problema y de la siguiente forma:
En el código que puse antes trato de mandar ciertas cosas en el mensaje... pero eso no es reconocido por todos los webmails asique hago lo siguiente:
PHP:
...
//En vez de tratar de mandar algo como contenido lo dejo vacío y agrego todo en los headers
$cabeceras .= $mensaje;
...
                if(mail($l, $asunto,' ', $cabeceras)) {
...
De esta forma se que funciona, de todas formas gracias por tu intención
 

Reclutador

Active Member
Messages
3,866
Reaction score
0
Points
36
Lo que te intenta decir es que en vez de usar hotmail, uses otra, como Gmail. logicamente cada "empresa" tiene sus propios servidores, y en vez de usar pop.hotmail.com te dice que uses pop.google.com (o pop.gmail.google.com, depende de su servidor pop)
 

avedillowebmaster

New Member
Messages
90
Reaction score
0
Points
0
Unas cosillas, cuando tienes un Newsletter no puedes elegir los servidores pop a los que va a ir, porque depende de los usuarios que estén apuntados, y tu deber como webmaster es que le llegue la información a todos.Cuando usas la función mail() de php estás usando el servidor smtp del servidor donde tienes alojada la web, con lo que si existen problemas con el envío, habría que buscar soluciones en el script o en ese servidor. Mi página en PHP-NUKE estuvo un tiempo sin poder mandar emails a hotmail, pero si a todos los demás pop, sin saber como ni porqué se solucionó y hasta hoy ha funcionado bien.
Un saludo.
 

cetutnx1

New Member
Messages
510
Reaction score
0
Points
0
Creo que no entendieron... el problema que yo tenía era un problema de programación no de servidores... ahora... gracias por los tips modificaré mi scrip para ver si puedo usar otro servidor de que no sea este...

Gonzalo.
 

avedillowebmaster

New Member
Messages
90
Reaction score
0
Points
0
Ciertamente leí que tenías un problema con el script, no obstante aproveché para comentar mi caso, por si alguién tiene algún problema similar con hotmail, el smtp de exofire estuvo un tiempo que al menos desde mi cuenta no enviaba emails a @hotmail.com. En cualquier caso ya lo solucionaste con lo que se puede cerrar el tema.

Un saludo.
 
Status
Not open for further replies.
Top