Guest User

Untitled

a guest
May 6th, 2018
550
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.78 KB | None | 0 0
  1. $mail->AddAddress($email ,"$row->email"); so I had to replace this line with
  2. $mail->AddAddress('@gmail.com'); I guess this happens because it doesn't get the data
  3.  
  4.  
  5.  
  6.  
  7. <?php
  8. $servername = "";
  9. $username = "";
  10. $password = "";
  11. $dbname = "";
  12.  
  13. // Create connection
  14. $conn = new mysqli($servername, $username, $password, $dbname);
  15. // Check connection
  16. if ($conn->connect_error) {
  17. die("Connection failed: " . $conn->connect_error);
  18. }
  19.  
  20. echo "Connected successfully";
  21.  
  22. ob_start();
  23. echo "Connected successfully";
  24.  
  25. require_once('class.phpmailer.php');
  26. include("class.smtp.php"); // optional, gets called from within class.phpmailer.php if not already loaded
  27.  
  28.  
  29. $mail = new PHPMailer();
  30.  
  31.  
  32.  
  33. $mail->IsSMTP(); // telling the class to use SMTP
  34. $mail->Host = "smtp.gmail.com"; // SMTP server
  35. $mail->SMTPDebug = 1; // enables SMTP debug information (for testing)
  36. // 1 = errors and messages
  37. // 2 = messages only
  38. $mail->SMTPAuth = true; // enable SMTP authentication
  39. $mail->SMTPSecure = "tls"; // sets the prefix to the servier
  40. $mail->Host = "smtp.gmail.com"; // sets GMAIL as the SMTP server
  41. $mail->Port = 587; // set the SMTP port for the GMAIL server
  42. $mail->Username = "@gmail.com"; // GMAIL username
  43. $mail->Password = ""; // GMAIL password
  44.  
  45.  
  46. include("config.php");
  47.  
  48.  
  49. if(isset($_GET['emailaddress']))
  50. {
  51.  
  52. $emailaddress= mysqli_real_escape_string($conn, $_GET['emailaddress']);
  53.  
  54. echo $emailaddress;
  55.  
  56. //$sql= "SELECT username,password FROM users WHERE email = $emailaddress";
  57. $query = mysqli_query ( $conn, "SELECT username,password FROM users WHERE email = $emailaddress" );
  58. //$query = mysqli_query ( $conn, $sql );
  59.  
  60. $row = mysqli_fetch_object($query);
  61. $strMessage = "<table>
  62. <tr>
  63. <td>User name : </td>
  64. <td> $row->username </td>
  65. <td>Password : </td>
  66. <td> $row->password </td>
  67. </tr>
  68. </table>";
  69. $mail->SetFrom('@gmail.com', 'FromName');
  70.  
  71. $email = mysqli_real_escape_string($conn, $_POST['email']);
  72. $mail->AddAddress('@gmail.com');
  73.  
  74. //$mail->AddAddress($email ,"$row->email");
  75. $mail->Subject = "Account Details";
  76.  
  77. $mail->AltBody = "To view the message, please use an HTML compatible email viewer!"; // optional, comment out and test
  78.  
  79. $mail->Body = $strMessage;
  80.  
  81. if($mail->Send())
  82. {
  83. echo "<script> alert('Mail succesfully sent to $email.'); </script>.";
  84. echo '<META HTTP-EQUIV="Refresh" Content="0; URL=mainpage.php">';
  85. exit;
  86. }
  87. else
  88. {
  89. echo "<div align=center style="color:#FF0000; font-family: 'Times New Roman', Times, serif; font-size: 26px;"> Cannot send mail. $mail->ErrorInfo. </div>";
  90. }
  91. }
  92.  
  93. ob_flush();
  94. $conn->close();
  95.  
  96.  
  97. ?>
Add Comment
Please, Sign In to add comment