2
votes

I tried many site but I can't find the result what I want to do.so anybody can please help me to solve this ?

My problem is : I want to send forgot password email to client.which is expire after 15 min.Here is my code

    function send_email($to, $subject, $message)
        {
            global $from_email;
            global $from_pwd;
            global $host;

            $mail = new PHPMailer();  
            $mail->IsSMTP();
            $mail->ContentType = "text/html";
            $mail->Host = $host;
            $mail->Port = 465;
            $mail->SMTPAuth = true;
            $mail->SMTPSecure = 'ssl';
            $mail->Username = $from_email;
            $mail->Password = $from_pwd;
            $mail->From     = $from_email;
            $mail->AddAddress($to);
            $mail->Subject  = $subject;
            $mail->Body     = $message;


            if(!$mail->Send()) {
                die('Message was not sent.'.$mail->ErrorInfo);
            }
        }


And I also Added This code


    //Send Welcome Email
    require_once("classes/class.phpmailer.php");
    send_email($_POST["email"],"Thanks For Register", "Php Link is here");


1
The timeout isn't something you set in the email itself, if you want your link to expire in 15 minutes, you'd want to store the date it was created,a nd the validity dat in a database, and when someone clicks the link, check if the current date is older than the validity date and if it is, decline the reset because it's too old.Zachary Craig

1 Answers

3
votes

There are so many ways to achieve this like:

  • While sending the email make an entry in the datatabse table with the time on email send and put the check to compare the time with given time limit and show the message if time exceeds.
  • Send an extra pramater in the link that contains timestamp or encrypted time in it, compare it with the time of clicked time and show the message.