Ir al contenido


Foto

No llegan nunca correos al destinatario funcion mail y phpmailer


  • Por favor identifícate para responder
1 respuesta en este tema

#1 shinneo

shinneo

    Newbie

  • Miembros
  • Pip
  • 6 mensajes

Escrito 25 agosto 2014 - 02:47

Hola, estoy en el tutorial 53 de cesar cansino de PHP POO, estoy siguiendo paso por paso sus indicaciones pero no consigo que el correo llegue nunca, elija el servidor que elija, he probado con hotmail, yahoo, y gmail y nada de nada, no llega ni a la bandeja de correo no deseado.
Llevo una semana dandole vueltas y no consigo que llegue nunca al correo, de hecho he probado con php mailer siguiendo el tutorial 37 y tampoco llega.
He cambiado de hosting y tampoco llega, he comprobado los registros de la base de datos en el hosting y estan correctos, ya que de otro modo no puedo enviar el correo(si no esta en la base de datos)
Este es el formulario.


delphi
  1. <?php
  2. require_once("class/class.php");
  3. if (isset($_POST["grabar"])and $_POST["grabar"]=="si")
  4. {
  5.     $trabajoinstan = new Trabajo;
  6.     $trabajoinstan->olvido_contraseña();
  7. }
  8.  
  9. ?>
  10.  
  11. <html>
  12.  
  13. <head>
  14. <META HTTP-EQUIV="Content-Type" CONTENT="text/html; charset=UTF-8">
  15. <link  type="text/css" rel="stylesheet" href="css/estilos.css"/>
  16. <script language="javascript" type="text/javascript" src="js/funciones.js">
  17. </script>
  18. <script language="javascript" type="text/javascript" src="js/md5.js">
  19. </script>
  20.  
  21. <title>SISTEMAS DE ENCUESTAS</title>
  22. </head>
  23.  
  24.  
  25. <body onload="borrado();" >
  26. <center>
  27. <h1 id="tituloh1">SISTEMAS DE ENCUESTAS</h1>
  28. <fieldset id="barralogin">
  29.     <a  href="registro.php" title="registro">Registrarse</a>
  30.     ||
  31.     <a  href="index.php" title="login">Login</a>
  32. </fieldset>
  33. <hr />
  34. </center>
  35. <center>
  36. <fieldset id="fondoverde">
  37.     <legend><strong>Reestablecer mi contraseña</strong></legend>
  38.     <form action="" method="POST" name="formulariox">
  39.         <table>
  40.  
  41.             <tr>
  42.                 <td id="cabecera">Email</td>
  43.                 <td id="cabeceradatos"><input type="text" name="correo" /></td>
  44.             </tr>
  45.        
  46.          
  47.             <div id="error"></div>
  48.             <tr>
  49.                 <td id="cabecera"><input type="hidden" name="grabar" value="si" /></td>
  50.                 <td id="cabeceradatos"><input id="boton" type="button" value="INGRESAR DATOS USUARIO" onclick="olvido();"/></td>
  51.             </tr>
  52.         </table>
  53.        
  54.     </form>
  55. </fieldset>
  56. </center>
  57. </body>
  58. </html>


Este es olvido() de javascript, en el onclick abajo del formulario


delphi
  1.   function olvido()
  2. {
  3.    
  4.  
  5.     if (document.formulariox.correo.value==0)
  6.     {
  7.  
  8.         document.getElementById('error').innerHTML="<font color='red'><strong>El campo CORREO esta completamente vacio</strong></font>";
  9.         document.formulariox.correo.focus();
  10.         return false;
  11.     }


y por ultimo olvido_contraseña() llamado al principio del formulario



delphi
  1.     public function olvido_contraseña()
  2.            
  3.     {
  4.    
  5.          
  6.           $sql="select * from usuarios where correo ='".$_POST["correo"]."' ";
  7.                 $consulta=  mysql_query($sql,  Conectar::Conex());
  8.           if (mysql_num_rows($consulta)!=0)
  9.           {
  10.                 echo "el campo correo existe y bien";
  11.                 while ($reg = mysql_fetch_array($consulta))
  12.                 {
  13.                         $nombre=$reg["nombre"];
  14.                         $id_usuario=$reg["id_usuario"];
  15.                 }
  16.       ////////////////////////////////////envio de correo/////////////////////////////////////////////////
  17.          
  18.                                   $mi_mail=$_POST["correo"];
  19. $remitente="Tuto 53 PHP POO<correopersonalizado@shinneo.es>";
  20.  
  21. $asunto="Tutorial 53 PHP POO"; //Asunto
  22. $cuerpo="
  23. <html>
  24.                                 <head>
  25.                                
  26. <body>
  27. <h2>Hola $nombre </h2>
  28.  
  29. Para restablecer tu contraseña entra en el siguiente enlace:
  30.  
  31. Atentamente el equipo de Programadores
  32. </body>
  33. </html>
  34.  
  35. "; //mensaje
  36.  
  37. $sheader="From:".$remitente."\nReply-To:".$remitente."\n";
  38. $sheader=$sheader."X-Mailer:PHP/".phpversion()."\n";
  39. $sheader=$sheader."Mime-Version: 1.0\n";
  40. $sheader=$sheader."Content-Type: text/html";
  41. echo $cuerpo;
  42.                                 echo "<br />";
  43.                                 echo $asunto;
  44.                                 echo "<br />";
  45.                                 echo $mi_mail;
  46.                              
  47. mail($mi_mail,$asunto,$cuerpo,$sheader);
  48. //header("Location: olvido.php?m=2");
  49.                                 exit;
  50.     ////////////////////////////////////fin de envio de correo/////////////////////////////////////////////////
  51.           }
  52.           else
  53.           {
  54.              
  55.                       echo '<div id="rojo">EL CAMPO INTRODUCIDO NO EXISTE EN LA BASE DE DATOS</div>';
  56.                  
  57.           }
  58.      
  59.     } 



Espero que alguien me pueda ayudar.
Gracias.
  • 0

#2 sebatec

sebatec

    Newbie

  • Miembros
  • Pip
  • 1 mensajes

Escrito 25 agosto 2014 - 09:16

Estimado,
soy nuevo en el foro, pero te paso este codigo quiza puedas ajustar a tu conveniencia.
He implementado algunos formularios de contacto con mails, y me han funcionado.
tengo 2 alternativas, una nativa de php y tu servidor de hosting, que es la que te pego ahora, y sino con phpmailer que es la que uso en un sistema de reclamos que he programado para envios automaticos.

Codigo:



delphi
  1. <?php
  2. //esto lo use yo personalmente pasando una variable para cuando seleccionan una propiedad
  3. if($_REQUEST["consulta1"]!=""){
  4. $link='<a href="xxxxxxxxxxxx.php?id='. $_REQUEST["consulta1"] .'">Ver propiedad seleccionada</a>';
  5. }else{
  6. $link="No hay propiedad especifica de consulta.";
  7. }
  8.  
  9.  
  10.  
  11. $to = 'info@xxxxxx.com.xx'; //Para
  12. $subject = 'Contacto WEB '.$_POST["nombre"];//Se define el asunto
  13.  
  14. //so we use the MD5 algorithm to generate a random bash
  15. $random_hash = md5(date('r', time()));
  16. $fecha= date("Y-m-d");
  17. $nombre= $_POST["nombre"];
  18. $apellido= $_POST["apellido"];
  19. $telefono= $_POST["telefono"];
  20. $mail= $_POST["email"];
  21. $consulta= $_POST["consulta"];
  22.  
  23. //Se definen las cabezeras separadas por \r\n
  24.  
  25. $headers = "From: contactoweb@xxxxxxx.com.xx";//Remitente
  26. $headers .= "\r\nContent-Type: text/html; boundary=\"PHP-alt-".$random_hash."\"";
  27.  
  28. //define el cuerpo del mensaje en HTML.
  29. ob_start(); //Turn on output buffering
  30.  
  31. ?>
  32. <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
  33. <html xmlns="http://www.w3.org/1999/xhtml">
  34. <head>
  35. <meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1" />
  36. <style type="text/css">
  37. <!--
  38. .opciones {
  39. border-bottom-width: 1px;
  40. border-bottom-style: solid;
  41. border-bottom-color: #0066FF;
  42. }
  43. .items {
  44. font-family:Georgia, "Times New Roman", Times, serif;
  45. font-size: 10px;
  46. word-spacing: normal;
  47. }
  48. .titulo {
  49. font-size: 20px;
  50. font-style: normal;
  51. font-family:"Century Gothic";
  52. text-decoration:underline;
  53. color: #298cb3;
  54. letter-spacing: 1pt;
  55.  
  56. }
  57. .resp {
  58. font-family: "Century Gothic";
  59. font-size: 10px;
  60. color: #333333;
  61. }
  62. .data2{
  63. border:solid;
  64. border-width:2px;
  65. border-color:#000;
  66. }
  67. .tabla{
  68. border:solid;
  69. border-width:1px;
  70. border-color:#000;
  71. }
  72. -->
  73. </style>
  74. </head>
  75. <body leftmargin="20" topmargin="0">
  76.       <table class="tabla" width="790" border="0" cellspacing="5" cellpadding="0">
  77.         <tr>
  78.           <td colspan="4" align="center" valign="top" class="titulo"><img src="http://xxxxxxxx.com.xxx/img/logo_mini.jpg" ><br />
  79.           Contacto WEB<br /></td>
  80.         </tr>
  81.         <tr>
  82.           <td width="13%" align="right" valign="top"><strong>Nombre:</strong></td>
  83.           <td width="21%" align="left" valign="top">&nbsp;<?php  echo "$nombre"; ?></td>
  84.           <td width="20%" align="right" valign="top"><strong>Email:</strong></td>
  85.           <td width="46%" align="left" valign="top">&nbsp;<?php  echo "$mail"; ?></td>
  86.         </tr>
  87.         <tr>
  88.           <td align="right" valign="top"><strong>Apellido:</strong></td>
  89.           <td align="left" valign="top">&nbsp;<?php  echo "$apellido"; ?></td>
  90.           <td align="right" valign="top"><strong>Fecha del contacto:</strong></td>
  91.           <td align="left" valign="top">&nbsp;<?php  echo "$fecha"; ?></td>
  92.         </tr>
  93.         <tr>
  94.           <td align="right" valign="top"><strong>Tel&eacute;fono:</strong></td>
  95.           <td align="left" valign="top"><?php  echo "$telefono"; ?></td>
  96.           <td align="right" valign="top"><strong>Link:</strong></td>
  97.           <td align="left" valign="top"><?php  echo "$link"; ?></td>
  98.         </tr>
  99.         <tr>
  100.           <td align="right" valign="top">&nbsp;</td>
  101.           <td colspan="3" align="left" valign="top">&nbsp;</td>
  102.         </tr>
  103.         <tr>
  104.           <td align="right" valign="top"><strong>Consulta:</strong></td>
  105.           <td colspan="3" align="left" valign="top"><?php  echo "$consulta"; ?></td>
  106.         </tr>
  107.     </table>
  108. </body>
  109.  
  110. <?
  111.  
  112. $header = header("Location:send_feedback.php?mail=$mail"); //otro php que envia un feedback al usuario diciendo que será comunicado a la brevedad
  113. //copy current buffer contents into $message variable and delete current output buffer
  114. $message = ob_get_clean();
  115. //send the email
  116. $mail_sent = @mail( $to, $subject, $message, $headers );
  117. //if the message is sent successfully print "Mail sent". Otherwise print "Mail failed"
  118. echo $mail_sent ? "Formulario enviado con éxito, muchas gracias." : "Error al intentar enviar el formulario, por favor intente nuevamente en un rato.";
  119. ?>




Aqui deberás jugar con el codigo para ver si te resulta, de todas formas tengo otro codigo con la clase phpmailer.

saludos,
  • 0




IP.Board spam blocked by CleanTalk.