Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- $mail->AddAddress($email ,"$row->email"); so I had to replace this line with
- $mail->AddAddress('@gmail.com'); I guess this happens because it doesn't get the data
- <?php
- $servername = "";
- $username = "";
- $password = "";
- $dbname = "";
- // Create connection
- $conn = new mysqli($servername, $username, $password, $dbname);
- // Check connection
- if ($conn->connect_error) {
- die("Connection failed: " . $conn->connect_error);
- }
- echo "Connected successfully";
- ob_start();
- echo "Connected successfully";
- require_once('class.phpmailer.php');
- include("class.smtp.php"); // optional, gets called from within class.phpmailer.php if not already loaded
- $mail = new PHPMailer();
- $mail->IsSMTP(); // telling the class to use SMTP
- $mail->Host = "smtp.gmail.com"; // SMTP server
- $mail->SMTPDebug = 1; // enables SMTP debug information (for testing)
- // 1 = errors and messages
- // 2 = messages only
- $mail->SMTPAuth = true; // enable SMTP authentication
- $mail->SMTPSecure = "tls"; // sets the prefix to the servier
- $mail->Host = "smtp.gmail.com"; // sets GMAIL as the SMTP server
- $mail->Port = 587; // set the SMTP port for the GMAIL server
- $mail->Username = "@gmail.com"; // GMAIL username
- $mail->Password = ""; // GMAIL password
- include("config.php");
- if(isset($_GET['emailaddress']))
- {
- $emailaddress= mysqli_real_escape_string($conn, $_GET['emailaddress']);
- echo $emailaddress;
- //$sql= "SELECT username,password FROM users WHERE email = $emailaddress";
- $query = mysqli_query ( $conn, "SELECT username,password FROM users WHERE email = $emailaddress" );
- //$query = mysqli_query ( $conn, $sql );
- $row = mysqli_fetch_object($query);
- $strMessage = "<table>
- <tr>
- <td>User name : </td>
- <td> $row->username </td>
- <td>Password : </td>
- <td> $row->password </td>
- </tr>
- </table>";
- $mail->SetFrom('@gmail.com', 'FromName');
- $email = mysqli_real_escape_string($conn, $_POST['email']);
- $mail->AddAddress('@gmail.com');
- //$mail->AddAddress($email ,"$row->email");
- $mail->Subject = "Account Details";
- $mail->AltBody = "To view the message, please use an HTML compatible email viewer!"; // optional, comment out and test
- $mail->Body = $strMessage;
- if($mail->Send())
- {
- echo "<script> alert('Mail succesfully sent to $email.'); </script>.";
- echo '<META HTTP-EQUIV="Refresh" Content="0; URL=mainpage.php">';
- exit;
- }
- else
- {
- echo "<div align=center style="color:#FF0000; font-family: 'Times New Roman', Times, serif; font-size: 26px;"> Cannot send mail. $mail->ErrorInfo. </div>";
- }
- }
- ob_flush();
- $conn->close();
- ?>
Add Comment
Please, Sign In to add comment