phpmailer is not taking the values from my database

Asked

Viewed 168 times

0

I’m trying to recover e-mail and password, where:

$o_email = $_GET['email'];
$celular = $_GET['celular'];

Receives via URL the user’s email or mobile phone. But I am not able to get these recovered data to play in phpmailer.

What could I be doing wrong?

<?php


header('Content-type: application/json; charset=iso-8859-1"');
header('Access-Control-Allow-Origin: *');


include 'database.php';
include '../phpMailer/PHPMailerAutoload.php';

$o_email = $_GET['email'];
$celular = $_GET['celular'];


                $consulta = $pdo->prepare("SELECT nome, email, senha, celular FROM usuario_app WHERE email = '$o_email' OR (celular = '$celular')");
                $consulta->execute();

                $linha = $consulta->rowCount();

                foreach($consulta as $mostra):
                    $nome = addslashes(strip_tags($mostra['nome']));
                    $email = addslashes(strip_tags($mostra['email']));   
                    $senha = addslashes(strip_tags($mostra['senha']));   
                endforeach;  

                if($linha):                   
                    $_SESSION['nome'] = $nome;
                    $_SESSION['email'] = $email;                     
                    $_SESSION['senha'] = $senha;  
                endif;  

echo $nome;
echo $email;
echo $senha;


 $html = 'Olá ' . $nome . ', você pediu para recuperar sua senha. <br></br>


A sua senha é: ' .  $senha . '
<br></br>
Atenciosamente,
<br></br>
<b>Equipe VovóCooks,</b>
www.vovocooks.com.br';



$mail = new PHPMailer;

//$mail->SMTPDebug = 3;                               // Enable verbose debug output

$mail->isSMTP();                                      // Set mailer to use SMTP
$mail->Host = 'smtp.zoho.com';  // Specify main and backup SMTP servers
$mail->SMTPAuth = true;                               // Enable SMTP authentication
$mail->Username = '[email protected]';                 // SMTP username
$mail->Password = 'sucessomundial2017';                           // SMTP password
$mail->SMTPSecure = 'tls';                            // Enable TLS encryption, `ssl` also accepted
$mail->Port = 587;                                    // TCP port to connect to

$mail->setFrom('[email protected]', 'VovoCooks App');
//$mail->addAddress('[email protected]', 'VovóCooks App');     // Add a recipient
$mail->addAddress($email);               // Name is optional

$mail->isHTML(true);                                  // Set email format to HTML

$mail->Subject = 'Seu login e senha do VovoCooks App.';
$mail->Body    = $html;




if(!$mail->send()) {
    echo 'A mensagem não pode ser enviada.';
    echo 'Mailer Error: ' . $mail->ErrorInfo;   
} else {
    echo 'Mensagem enviada';
    echo json_encode(array('message'=> 'Sua senha foi enviada para seu e-mail: ' + $to));
}


?>
  • In this your code above there are no errors. I tested on my server and works correctly. Maybe there is error in the form, path of includes. Post the form.

1 answer

1


the error is in the url see which is $_GET['email']; and not $_GET['o_email'];

has to be ....?email=.... and not ....?o_email=....

http://meusite.com.br/admin/apis/esqueci/[email protected]

or

http://meusite.com.br/admin/apis/esqueci/esqueci_netinho.php?celular=99......
  • I’ve tried this before. But even so, it returns me the error message: The message cannot be sent.Mailer Error: You must provide at least one recipient email address.

  • For example, I came back as you spoke the answer and went back to SQL: $query = $Pdo->prepare("SELECT name, email, password, cell phone FROM usuario_app WHERE email = '$email' OR (cell phone = '$cell phone')")....

  • There is, I’ve checked the table and the written form.

  • 1

    see if you got anything in your CP

  • It worked in another table that has the same purpose. I’ll see what can be in this table. It may be that the email has been deleted, I do not know. But show it to me here.... at least curious. But thank you @Leo Caracciolo!

  • 1

    beauty, good luck

  • 1

    better delete comments with your email so you don’t get exposed

Show 2 more comments

Browser other questions tagged

You are not signed in. Login or sign up in order to post.