Ver Mensaje Individual
  #6 (permalink)  
Antiguo 04/01/2015, 14:04
eslomao
 
Fecha de Ingreso: noviembre-2014
Mensajes: 60
Antigüedad: 9 años, 5 meses
Puntos: 0
Respuesta: error envio email

por fin llego, uffffffffffffff , os pongo el codigo por si a alguien le sirve

Código HTML:
Ver original
  1. <div class="wrap">
  2.             <header>
  3.                 Enviar mail desde localhost con PHP Mailer
  4.             </header>
  5.  
  6.            <section id="principal">
  7.                 <form id="formulario" method="post" action="mail.php" enctype="multipart/form-data">
  8.                     <div class="campos">
  9.                         <label>Para:</label>
  10.                         <input type="email" name="email" required>
  11.                     </div>
  12.                     <div class="campos">
  13.                         <label>Asunto:</label>
  14.                         <input type="text" name="asunto">
  15.                     </div>
  16.                     <div class="campos">
  17.                         <label>Mensaje:</label>
  18.                         <textarea name="mensaje"></textarea>
  19.                     </div>
  20.  
  21.                     <label>Imagen:</label>
  22.                     <input type="file" name="hugo" id="imagen" />
  23.  
  24.                     <input id="submit" type="submit" name="enviar" value="Enviar mail">
  25.                 </form>
  26.  
  27.             </section>
  28.         </div>
  29.     </body>
  30. </html>

php mailer el siguiente

Código PHP:
Ver original
  1. <?php
  2. //Librerías para el envío de mail
  3. include_once('class.phpmailer.php');
  4. include_once('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. $archivo = $_FILES['hugo'];
  11.  
  12. //Este bloque es importante
  13. $mail = new PHPMailer();
  14. $mail->IsSMTP();
  15. $mail->SMTPAuth = true;
  16. $mail->SMTPSecure = "ssl";
  17. $mail->Host = "smtp.gmail.com";
  18. $mail->Port = 465;
  19.  
  20. //Nuestra cuenta
  21. $mail->Username ='@gmail.com'; su correo
  22. $mail->Password = 'xxxx'; //Su password
  23.  
  24. //Agregar destinatario
  25. $mail->AddAddress($para);
  26. $mail->Subject = $asunto;
  27. $mail->Body = $mensaje;
  28. //Para adjuntar archivo
  29. $mail->AddAttachment($archivo['tmp_name'], $archivo['name']);
  30. $mail->MsgHTML($mensaje);
  31.  
  32. //Avisar si fue enviado o no y dirigir al index
  33. if($mail->Send())
  34. {
  35.     echo'<script type="text/javascript">
  36.            alert("Enviado Correctamente");
  37.            window.location="envioemal.php"
  38.         </script>';
  39. }
  40. else{
  41.     echo'<script type="text/javascript">
  42.            alert("NO ENVIADO, intentar de nuevo");
  43.            window.location="envioemal.php"
  44.         </script>';
  45. }
  46. ?>