Problem sa php mail() funkcijom.

alex095

Početnik
Poruka
1
Pozdrav, imam problem sa mail() funkcijom, jednostavano nece da posalje mejl. Ovde email adresu izvlacim iz baze, a ne radi ni kada direktno u kodu upisem email adresu.
Moze li mi neko pomoci oko ovog problema.

Ovo je moj kod.
PHP:
<?php
include 'header.php';

$errors = [];

//Logovanje
if(isset($_POST['submit']))
{
    $email = mysqli_real_escape_string($con, $_POST['email']);
    // ensure that the user exists on our system
    $query = "SELECT email FROM users WHERE email='$email'";
    $results = mysqli_query($con, $query);

    if (empty($email)) {
        array_push($errors, "Your email is required");
    }else if(mysqli_num_rows($results) <= 0) {
        array_push($errors, "Sorry, no user exists on our system with that email");
    }
    // generate a unique random token of length 100
    $token = bin2hex(random_bytes(50));

    if (count($errors) == 0) {
        // store token in the password-reset database table against the user's email
        $sql = "INSERT INTO password_resets(email, token) VALUES ('$email', '$token')";
        $results = mysqli_query($con, $sql);

        // Send email to user with the token in a link they can click on
        $to = $email;
        $subject = "Reset your password on tabloidor.com";
        $msg = "Hi there, click on this <a href=\"new-password.php?token=" . $token . "\">link</a> to reset your password on our site";
        $msg = wordwrap($msg,70);
        $headers = "From: tabloidor@incrementcode.com\r\n";
        $headers.= "MIME-Version: 1.0\r\n";
        $headers.= "Content-Type: text/html; charset=UTF-8\r\n";
        $headers.= "X-Priority: 1\r\n";
        mail($to, $subject, $msg, $headers);
        header('location: pending.php?email=' . $email);
    }
}
?>
 

Back
Top