Tema: phpmailer
Ver Mensaje Individual
  #1 (permalink)  
Antiguo 25/01/2015, 15:27
eslomao
 
Fecha de Ingreso: noviembre-2014
Mensajes: 60
Antigüedad: 9 años, 5 meses
Puntos: 0
phpmailer

hola chicos, estoy tratando de mandar un mail con php mailer, pero hay datos que no me llegan, otros si, os dejo parte del codigo a ver si me ayudais

Código HTML:
Ver original
  1. <form id="formulario" method="post" action="mail.php" enctype="multipart/form-data">
  2.          <table width="513" height="130" align="right" bgcolor="#EEEEEE">
  3.   <tr>
  4.     <td width="56" height="15">Email: </td>
  5.    <td width="146"> <input type="email" name="email" class="campo" required></td>  
  6.    <td width="61"> <label>Nombre:</label></td>        
  7.    <td width="142"><input name="nombre" type="text" class="campo" ></td>        
  8.    </tr>        
  9.           <tr>
  10.  <td><label>Ciudad:</label></td>
  11.  <td><input type="text" name="ciudad" class="campo" required  ></td>
  12.  <td><label>Direccion:</label></td>
  13.  <td><input type="text" name="direccion" class="campo" required></td>
  14.     </tr>
  15.            <tr>
  16.   <td><label>Telefono:</label></td>
  17.  <td><input type="text" name="telefono" class="campo"  required></td>
  18.  <td> <label>Asunto:</label></td>
  19.  <td><input name="asunto" type="text" class="campo" value="Compra realizada" readonly="readonly"></td>
  20.  </tr>
  21.       <tr>
  22.     <td><label></label> <input name="mensaje" type="hidden" value="Gracias por comprar en la cachemira.com, <br />
  23. a continuacion le remitimos el total de su compra, esperamos verle pronto. El total de su compra IVA incluido es de <?php echo $total; ?> Euros " readonly="readonly"></textarea>
  24.           </td> </tr>
  25.   <tr>
  26.     <td height="34"> </td>
  27.  <td><input id="submit" type="submit" name="enviar" value="Enviar mail"></td>  
  28.     </tr>
  29.   </table></form>

y este es quien procesa los datos y los manda a gmail

Código PHP:
Ver original
  1. <?php
  2. //Librerías para el envío de mail
  3. include_once('phpmailer/class.phpmailer.php');
  4. include_once('phpmailer/class.smtp.php');
  5.  
  6. //Recibir todos los parámetros del formulario
  7. $para = $_POST['email'];
  8. $asunto = $_POST['asunto'];
  9. $mensaje = $_POST['mensaje'];
  10. $direccion= $_POST['direccion'];
  11. $ciudad = $_POST['ciudad'];
  12. $telefono = $_POST['telefono'];
  13. $nombre = $_POST['nombre'];
  14. //Este bloque es importante
  15. $mail = new PHPMailer();
  16. $mail->IsSMTP();
  17. $mail->SMTPAuth = true;
  18. $mail->SMTPSecure = "ssl";
  19. $mail->Host = "smtp.gmail.com";
  20. $mail->Port = 465;
  21.  
  22. //Nuestra cuenta
  23. $mail->Username ='[email protected]';
  24. $mail->Password = 'xxxxxxx'; //mi password
  25.  
  26. //Agregar destinatario
  27. $mail->AddAddress($para);
  28. $mail->Subject = $asunto;
  29. $mail->Body = "mensaje:$mensaje <br />".
  30.  "direccion: $direccion \n <br />".
  31.  "ciudad:$ciudad <br />".
  32.  "nombre:$nombre <br />".
  33.  "telefono: $telefono <br />
  34. ";
  35. $mail->direccion=$direccion;
  36. $mail->telefono=$telefono;
  37.  
  38.  
  39. //Para adjuntar archivo
  40.  
  41. $mail->MsgHTML($mensaje,$asunto,$direccion,$direccion);
  42.  
  43. //Avisar si fue enviado o no y dirigir al index
  44. if($mail->Send())
  45. {
  46.     echo'<script type="text/javascript">
  47.            alert("Enviado Correctamente");
  48.            window.location="finalizar.php"
  49.         </script>';
  50. }
  51. else{
  52.     echo'<script type="text/javascript">
  53.            alert("NO ENVIADO, intentar de nuevo");
  54.            window.location="finalizar.php"
  55.         </script>';
  56. }
  57. ?>


"direccion: $direccion \n <br />".
"ciudad:$ciudad <br />".
"nombre:$nombre <br />".
"telefono: $telefono <br />
";

esa parte es la que no me llega, el resto no hay problemas, el mensaje con el total de la compra, el asusnto y quien lo manda si,