Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- function invio_email_psw()
- {
- global $con;
- $email = $con->real_escape_string($_POST['email']);
- $query = "SELECT * FROM admin WHERE email = '$email'";
- // Perform queries and print out affected rows
- if ($ris = $con->query($query)) {
- /* fetch associative array */
- if (mysqli_affected_rows($con) > 0) {
- $row = $ris->fetch_assoc();
- $ID = $row['ID'];
- $hash = $row['pass'] . "" . $row['ID'];
- require 'PHPMailer-master/PHPMailerAutoload.php';
- $mail = new PHPMailer;
- $mail->isSMTP();
- $mail->SMTPDebug = 2;
- $mail->Debugoutput = 'html';
- $mail->Host = 'smtp.gmail.com';
- $mail->Port = 587;
- $mail->SMTPSecure = 'tls';
- $mail->SMTPAuth = true;
- $mail->Username = "r.readellavolpe@gmail.com";
- $mail->setFrom('r.readellavolpe@gmail.com', 'First Last');
- $mail->addReplyTo('r.readellavolpe@gmail.com', 'First Last');
- $mail->addAddress('r.readellavolpe@gmail.com', 'John Doe');
- $mail->Subject = 'Reimposta la password di MyLIFE';
- $mail->Body = 'Abbiamo ricevuto la richiesta di reimpostare la password del tuo account ' . $email . ' <br> Fai Click sul link:
- <a href="localhost/login/login-ajax/reimposta_psw.php?id=' . $ID . '&code=' . $hash . '">LINK</a> per impostare una nuova password.';
- $mail->AltBody = 'This is a plain-text message body';
- if($mail->send()){
- $response_array['status'] = 'success';
- }
- }
- else{
- $response_array['status'] = 'error';
- }
- }
- echo json_encode($response_array);
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement