Implement change Password functionality

How to implement “forgot password” or change Password functionality in our application either Gmail, Yahoo or any other email accounts.