$telegram_id, 'text' => $message, 'parse_mode' => 'Markdown', // Use Markdown for formatting ]; // Use cURL to send the request $ch = curl_init(); // Construct the GET request URL $query_string = http_build_query($message_data); // Converts the array to URL-encoded query string $get_url = $url . '?' . $query_string; // Append query string to the base URL curl_setopt($ch, CURLOPT_URL, $get_url); curl_setopt($ch, CURLOPT_RETURNTRANSFER, true); // Still retrieve the response if needed curl_exec($ch); curl_close($ch); //send mail if(!empty($mail)){ $content = " Password Reset

Password Reset Request

Hi $mail,

You have requested a password reset link. Here it is:

Click here to reset your password

If you did not request this, please ignore this email. If you did, you can reset your password using the link above.

Request Details:

If this was you, you can reset your password. If this was not you, someone else may have tried to reset your password.

"; $message = [ "personalizations" => [ [ "to" => [ [ "email" => $mail ] ] ] ], "from" => [ "email" => $SENDGRID_MAIL ], "subject" => "Jakach login password reset", "content" => [ [ "type" => "text/html", "value" => $content ] ] ]; $url = "https://api.sendgrid.com/v3/mail/send"; // Initialize cURL $ch = curl_init($url); // Set cURL options curl_setopt($ch, CURLOPT_RETURNTRANSFER, true); curl_setopt($ch, CURLOPT_POST, true); curl_setopt($ch, CURLOPT_HTTPHEADER, [ "Authorization: Bearer $SENDGRID_KEY", "Content-Type: application/json" ]); curl_setopt($ch, CURLOPT_POSTFIELDS, json_encode($message)); // Execute the cURL request curl_exec($ch); curl_close($ch); } //insert the token into our db $valid_until=time()+8600; $sql="INSERT INTO reset_tokens (auth_token, user_id,valid_until) VALUES (?,?,?);"; $stmt = mysqli_prepare($conn, $sql); mysqli_stmt_bind_param($stmt, 'sii', $token,$id,$valid_until); mysqli_stmt_execute($stmt); mysqli_stmt_close($stmt); ?>