How to Send Forgot Password Link Programmatically in Magento 1.9

magento-1.9password

I have added all customers with the same password now I want to send the forgot password link programmatically to all customers.

I have tried below by creating the file in root.
Using below code i can send forgot password mail to the customer but when customer click on the password it display a blank screen with "http://127.0.0.1/magento1939/test.php/customer/account/resetpassword/?id=3&token=b3101c19f96551dea2e6f0a902b8c68f" URL

It redirect to same link
For Eg.
I have created test.php file and put below code. when i execute test.php file at that customer get reset password mail but when customer click on reset password mail they get link like "http://127.0.0.1/magento1939/**test.php**/customer/account/changeforgotten/" instead of "http://127.0.0.1/magento1939/customer/account/changeforgotten/" "

<?php
require_once('app/Mage.php'); //Path to Magento
umask(0);
Mage::app('default');
$yourCustomerEmail="bliss.jaimin@gmail.com";
$customer = Mage::getModel('customer/customer')
    ->setWebsiteId(Mage::app()->getStore()->getWebsiteId())
    ->loadByEmail($yourCustomerEmail);
if ($customer->getId()) {
    try {
        $newResetPasswordLinkToken =  Mage::helper('customer')->generateResetPasswordLinkToken();
        $customer->changeResetPasswordLinkToken($newResetPasswordLinkToken);
        $customer->sendPasswordResetConfirmationEmail();
    } catch (Exception $exception) {
        Mage::log($exception);
    }
}

In This email functionality is working perfect

Best Answer

You can add this code in index file with a condition like below

if($_GET['reset'] == 1 && isset($_GET['reset']))
{
.... Your Code for Email .....
}

Now run index.php with Like http://YOURSTORE_URL/index.php?reset=1