EDIT: my question is not a duplicate. I have a code, which I am presenting in my question, and I will be grateful for your help on finding my mistakes. Also, please, notice that I am using php mail() function, and not customized CS50 phpmailer functions; it is important for me to use php functions, not customized ones (although I, of course, use query and other functions created for this particular pset). Thank you for understanding.
I am struggling with pset7, but in a happy way because, although it's a hard task, I have learned a lot. Now I am doing reset password part. I am among less comfortable, but happy to learn this fascinating stuff. I will be grateful for help. Please, take a look at the code below. I don't see why mail() function doesn't send an email. I have checked all variables from query(), all are fine, and all display correct values, but email doesn't arrive.
http://php.net/manual/en/function.mail.php
<?php
// configuration
require("../includes/config.php");
if (isset($_SESSION["id"]))
{
$row = CS50::query("SELECT username, email FROM users WHERE id = ?", $_SESSION["id"]);
$email = $row[0]["email"];
$name = $row[0]["username"];
$salt = "3453#2K:90k≈“π631%380‘“HJK0D*7WPJ987NU";
// Create the unique user password reset key
$password = hash('sha512', $salt.$email);
// url to reset password
$reset_url = "https://ide50-name.cs50.io/new_password.php?q=".$password;
$email_subject = "Requested link from CS50 Finance web page";
//email the url
$email_body = "Dear $name,\n\nYou have requested to reset your password for CS50 Finance web page.
\n\nTo reset your password, please click the link below.\n\n".$reset_url."\n\nThank you!";
if(mail($email, $email_subject, $email_body))
{
// render form
render("email_link_form.php", ["email" => $email]);
}
}
else
{
redirect("login.php");
}
?>
Thank you very much!