0

I've got a problem, made reset password button but it wont send mail back.

I do have PHP mailer included, don't know why it wont send.

BTW before send I made query to check in DB for validation,that is working fine but just won't send ?!

Any suggestion ? no minuses -_-

$to = $userEmail;

$subject = 'Reset your password ,regards!';

$message = '<p>We recieve a password request</p>';
$message .= '<p>Here is your password reset link: </br>';
$message .= '<a href="' . $url . '">' . $url . '</a></p>';

$headers = "From: Fecy <pilifmaximus@gmail.com>\r\n";
$headers .= "Reply-To: pilifmaximus@gmail.com\r\n";
$headers .= "Content-type: text/html\r\n";


$sql = "SELECT * FROM users WHERE emailUsers =?";
$stmt = mysqli_stmt_init( $conn );
if ( ! mysqli_stmt_prepare( $stmt, $sql ) ) {
    header( "location: ../reset-pass.php?error=sqlerror" );
    exit();
} elseif ( mysqli_stmt_bind_param( $stmt, "s", $userEmail ) ) {
    mysqli_stmt_execute( $stmt );
    mysqli_stmt_store_result( $stmt );
    $resultCheck = mysqli_stmt_num_rows( $stmt );
    if ( $resultCheck > 0 ) {
        mail( $to, $subject, $message, $headers );
        header( "Location: ../reset-pass.php?reset=success" );
        exit();
    } else {
        header( "location: ../reset-pass.php?error=nomailfound" );
        exit();
    }
}
jrswgtr
  • 2,287
  • 8
  • 23
  • 49
Fecy
  • 15
  • 6
  • 2
    Does this answer your question? [PHP mail function doesn't complete sending of e-mail](https://stackoverflow.com/questions/24644436/php-mail-function-doesnt-complete-sending-of-e-mail) – jrswgtr Jan 02 '20 at 10:57
  • Sry ill check it out now! – Fecy Jan 02 '20 at 10:58
  • what error u got? – Rp9 Jan 02 '20 at 11:00
  • i do not get error,just email isnt send – Fecy Jan 02 '20 at 11:02
  • 1
    "I do have PHP mailer included"...ok, that's nice, but your code isn't making any use of it currently. It's a good idea to try and use it if you can though, it's usually better than using the raw `mail()` function. But anyway, try all the things that jrswgtr mentioned in the link first - there are a **lot** of reasons why emails may not be delivered (although please note that not **receiving** an email does not mean that the email was never **sent**. Your code's responsibility is to send the email only. Delivery is the responsibility of the mailservers on the route) – ADyson Jan 02 '20 at 11:20
  • thanks on reply AD – Fecy Jan 02 '20 at 12:11

0 Answers0