Well for starters you need have SMTP on your server, i trust you do.
Anyways when a user asks to have there password sent to them you either just get the password from the database and send it or generate a new one and change the database. Here is some general info
I suggest create a link with random number and user id and send it via user's email. All user need to do is just type in email and link with those details will be sent via that password (which must match database's email).
After clicking a link, then user will reset the password and either he will be taken to a form to change a password or the one-time-login password will be sent to a user (randomly generated) After login with one time login, force them to change that password
Hope it helps :)