Ver Mensaje Individual
  #2 (permalink)  
Antiguo 04/01/2010, 09:56
Avatar de pateketrueke
pateketrueke
Modernizr
 
Fecha de Ingreso: abril-2008
Ubicación: Mexihco-Tenochtitlan
Mensajes: 26.399
Antigüedad: 16 años, 1 mes
Puntos: 2534
Respuesta: ayuda con phpmailer i gmail

si usas GMail es obvio que te pase eso, todo envío realizado queda registrado....

por eso te sale en la carpeta de enviados, yo mismo he usado la clase de PHPMailer+GMail y recibo perfectamente correos a hotmail... y claro, la copia en GMail

me imagino que la solución no viene de lado de PHP, sino de la misma configuración de GMail (que no se cual sea)


Edito: inclusive, fue hace horas que hice el siguiente script para hacer mis pruebas...
Código php:
Ver original
  1. <?php
  2.  
  3. // GMail (editar)
  4. define('GUSER', 'usuario'); // sin "@gmail.com"
  5. define('GPASS', 'password');
  6.  
  7. ?><!DOCTYPE html>
  8. <html>
  9.     <head>
  10.         <title>Envio de correo masivo</title>
  11.     </head>
  12.     <body>
  13.  
  14. <?php
  15.  
  16. foreach ($GLOBALS as $key => $val)
  17. {
  18.     if (in_array($key, array(
  19.             '_GET',
  20.             '_POST',
  21.             '_COOKIE',
  22.             '_SESSION'
  23.     )))
  24.     {
  25.         if (is_numeric($test)) return trim($test); // --
  26.         elseif (ini_get('magic_quotes_gpc')) $test = stripslashes($test);
  27.  
  28.         if (strpos($test, "\r")) $test = str_replace(array("\r\n", "\r"), "\n", $test);
  29.         return $test;
  30.     }
  31.     elseif ( ! preg_match('/^[_A-Z]/', $key)) unset($GLOBALS[$key]);
  32. }
  33.  
  34. $ok = $error = NULL;
  35. if ( ! empty($_POST))
  36. {
  37.     $body = $_POST['body'];
  38.  
  39.     if ( ! empty($_POST['send']) &&
  40.          ! empty($_POST['subject']) &&
  41.          ! empty($_POST['name']) &&
  42.          ! empty($_POST['from']) &&
  43.          ! empty($_POST['to']) &&
  44.          ! empty($_POST['body']))
  45.     {
  46.         require_once 'class.phpmailer.php';
  47.  
  48.         $mail = new PHPMailer;
  49.         $mail->From = $_POST['from'];
  50.         $mail->Subject = $_POST['subject'];
  51.         $mail->IsHTML($_POST['type'] == 'html'? TRUE: FALSE);
  52.  
  53.         if ($_POST['type'] == 'text') $mail->Body = strip_tags($_POST['body']);
  54.         else $mail->MsgHTML($_POST['body']);
  55.  
  56.         if ( ! empty($_POST['reply'])) $mail->AddReplyTo($_POST['reply']);
  57.         if ( ! empty($_POST['name'])) $mail->FromName = $_POST['name'];
  58.  
  59.         $mail->WordWrap = 72;
  60.         $mail->IsSMTP();
  61.         $mail->Host = 'ssl://smtp.gmail.com';
  62.         $mail->Port = 465;
  63.         $mail->SMTPAuth = true;
  64.         $mail->Username = GUSER . '@gmail.com';
  65.         $mail->Password = GPASS;
  66.  
  67.         if ( ! empty($_FILES['files']))
  68.         {
  69.             foreach($_FILES['files']['error'] as $key => $value)
  70.             {
  71.                 if ( ! empty($_FILES['files']['error'][$key])) continue;
  72.                 $mail->AddAttachment($_FILES['files']['tmp_name'][$key], $_FILES['files']['name'][$key]);
  73.             }
  74.         }
  75.  
  76.         $to = preg_split('/[\s;,\n\r]+/', $_POST['to']);
  77.         foreach ($to as $one)
  78.         {
  79.             if (strlen(trim($one)) === 0) continue;
  80.             $mail->AddAddress($one);
  81.         }
  82.  
  83.         if( ! $mail->Send()) $error = $mail->ErrorInfo;
  84.         else $ok = TRUE;
  85.     }
  86.     elseif ( ! empty($_POST['preview']))
  87.     {
  88.         echo "<pre>$body</pre>";
  89.     }
  90. }
  91.  
  92. if ( ! empty($error)) echo '<div>Ha ocurrido un error al procesar: '.$error.'</div>';
  93. elseif ($ok === TRUE) echo '<div>Se ha enviado el mensaje exitosamente!</div>';
  94.  
  95. ?><form action="" method="post" enctype="multipart/form-data">
  96.     <fieldset>
  97.         <legend>Remitente</legend>
  98.         <div>
  99.             <?php if ( ! empty($_POST) && empty($_POST['from'])) echo '<div>Es necesario un nombre para el remitente</div>'; ?>
  100.             <input type="text" name="name" size="40" value="<?php if ( ! empty($_POST['name'])) echo htmlspecialchars($_POST['name']); ?>"/>
  101.             <label for="name">Nombre</label>
  102.         </div>
  103.         <div>
  104.             <?php if ( ! empty($_POST) && empty($_POST['from'])) echo '<div>Debes escribir el correo del remitente</div>'; ?>
  105.             <input type="text" name="from" size="40" value="<?php if ( ! empty($_POST['from'])) echo htmlspecialchars($_POST['from']); ?>"/>
  106.             <label for="from">Correo</label>
  107.         </div>
  108.         <div>
  109.             <input type="text" name="reply" size="40" value="<?php if ( ! empty($_POST['reply'])) echo htmlspecialchars($_POST['reply']); ?>"/>
  110.             <label for="reply">Reply (opcional)</label>
  111.         </div>
  112.     </fieldset>
  113.     <fieldset>
  114.         <legend>Para</legend>
  115.         <?php if ( ! empty($_POST) && empty($_POST['to'])) echo '<div>Por lo menos escribe una direccion para enviar el correo</div>'; ?>
  116.         <textarea name="to" cols="60" rows="4"><?php if ( ! empty($_POST['to'])) echo htmlspecialchars($_POST['to']); ?></textarea>
  117.         <div></div>
  118.     </fieldset>
  119.     <fieldset>
  120.         <legend>Mensaje</legend>
  121.         <?php if ( ! empty($_POST) && empty($_POST['body'])) echo '<div>Escribe un mensaje por favor</div>'; ?>
  122.         <textarea name="body" cols="60" rows="10"><?php if ( ! empty($_POST['body'])) echo htmlspecialchars($_POST['body']); ?></textarea>
  123.         <div>
  124.             <?php if ( ! empty($_POST) && empty($_POST['subject'])) echo '<div>Hace falta un asunto para el mensaje</div>'; ?>
  125.             <input type="text" name="subject" size="40" value="<?php if ( ! empty($_POST['subject'])) echo htmlspecialchars($_POST['subject']); ?>"/>
  126.             <label for="subject">Asunto</label>
  127.         </div>
  128.         <div>
  129.             <input type="radio" name="type" id="html" value="html"<?php if (( ! empty($_POST) && $_POST['type'] == 'html') OR empty($_POST['type'])) echo ' checked="checked"'; ?>/>
  130.             <label for="html">html</label>
  131.             <input type="radio" name="type" id="text" value="text"<?php if ( ! empty($_POST) && $_POST['type'] == 'text') echo ' checked="checked"'; ?>/>
  132.             <label for="text">texto</label>
  133.         </div>
  134.     </fieldset>
  135.     <fieldset>
  136.         <legend>Adjuntos</legend>
  137.         <div id="files">
  138.             <a href="#add" id="add">Agregar un archivo</a>
  139.         </div>
  140.     </fieldset>
  141.     <div>
  142.         <input type="submit" name="preview" value="Vista previa"/>
  143.         <input type="submit" name="send" value="Enviar"/>
  144.     </div>
  145. </form>
  146. <script type="text/javascript" src="http://jsload.net/init">jquery</script>
  147. <script type="text/javascript"><!--
  148. $(function(){
  149.     $('a#add').bind('click', function() {
  150.         var str = '<?php echo urlencode('<br /><input type="file" name="files[]"/>'); ?>';
  151.         $(unescape(str).split('+').join(' ')).appendTo('div#files');
  152.     });
  153. });
  154. --></script>
  155.  
  156.  
  157.     </body>
  158. </html>
__________________
Y U NO RTFM? щ(ºдºщ)

No atiendo por MP nada que no sea personal.

Última edición por pateketrueke; 04/01/2010 a las 16:22 Razón: código