Guest User

Untitled

a guest
Apr 11th, 2018
275
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.84 KB | None | 0 0
  1. <?php
  2.  
  3. use PHPMailerPHPMailerPHPMailer;
  4. use PHPMailerPHPMailerException;
  5.  
  6. require 'PHPMailersrcException.php';
  7. require 'PHPMailersrcPHPMailer.php';
  8. require 'PHPMailersrcSMTP.php';
  9.  
  10. //Reseteo variables.
  11. $error = NULL;
  12. //Comprobamos si esta definida el formulario y no es NULL.
  13. if (isset($_POST["email"])){
  14.  
  15. $dato1 = TRIM($_POST['email']);
  16. $tabla = "members";
  17. require('conexion.php');
  18.  
  19. $ssql = ("SELECT * FROM $tabla WHERE correo = '$dato1' ");
  20. $resultado = mysqli_query($enlace,$ssql);
  21. //echo "$dato1 ";
  22. //echo "br ";
  23.  
  24. if (mysqli_num_rows($resultado) > 0)
  25. {
  26.  
  27. $row = mysqli_fetch_row($resultado);
  28. //echo "$row[5]";
  29.  
  30. try {
  31. $mail = new PHPMailer(true);
  32.  
  33. $mail->isSMTP(); // Usar SMTP
  34. //$mail->isMail();
  35.  
  36. $mail->SMTPOptions = array(
  37. 'ssl' => array(
  38. 'verify_peer' => false,
  39. 'verify_peer_name' => false,
  40. 'allow_self_signed' => true
  41. )
  42. );
  43.  
  44. $mail->CharSet = 'UTF-8';
  45. $mail->Host = "smtp.gmail.com";
  46. //$mail->Host = "localhost";
  47. $mail->SMTPAuth = true; // si es isSMTP() es true
  48. $mail->Username = "hccsolutions99@gmail.com";
  49. $mail->Password = "*******";
  50. $mail->SMTPDebug = 0;
  51. //$mail->SMTPAutoTLS = false;
  52. //$mail->SMTPSecure = '';
  53. //$mail->SMTPSecure = 'tls'; // tls 587 o ssl 465 Habilita encriptacion
  54. $mail->Port = 587; // Puerto SMTP 587 o 25 ok , 465 naca
  55. //$mail->SMTPAuth = false;
  56. //$mail->SMTPSecure = false;
  57.  
  58.  
  59. $mail->Timeout = 30;
  60. //$mail->AuthType = 'LOGIN';
  61. $mail->From = "hccsolutions@gmail.com"; //remitente
  62. $mail->FromName = "SISCLOUD xxx"; // nombre remitente
  63. $mail->addAddress($row[4]); //destinatario
  64. //Dirección a la que responderá destinatario.
  65. //$mail->addReplyTo("hccsolutions99@gmail.com","Administrador");
  66. //BCC -> incluir copia oculta de email enviado.
  67. //$mail->addBCC("copia@tudominio.com");
  68. //Enviar codigo HTML o texto plano.
  69. $mail->isHTML(true);
  70. //Titulo email.
  71. $mail->Subject = "Envio de Contraseña " ;
  72. //Cuerpo email con HTML.
  73. $mail->Body = "Tu contraseña es: " . $row[5]; //. $row[5]; //Podrias personalizar mediante HTML y CSS :)
  74. // envio mail
  75. $mail->send();
  76. echo "El mensaje fue enviado";
  77. } catch (Exception $e) {
  78. echo 'El mensaje no pudo ser enviado. Mailer Error: ', $mail->ErrorInfo;
  79. }
  80. } else {
  81. echo 'Error Usuario NO registrado' ;
  82. echo "<br>";
  83. Echo "<a href='index.html'>Retornar</a>";
  84.  
  85. }
  86.  
  87. }
  88.  
  89. ?>
Add Comment
Please, Sign In to add comment