Password recovery and sending a user a random password are two different things.
Password recovery would be getting the current password from the database (or where ever it’s stored) and sending it to the user. In some cases, this may be impossible. For instance, if you’re storing a hash of the password, rather than the password itself, you won’t be able to retrieve that password (that’s why you’d do that, actually — for security purposes.)
A new password can be generated in a few ways. The easiest way is to use a random number generator, select several digits (6-10) with values between 0 and 62 then convert these numbers to [0-9a-zA-Z] to generate the password. This should give you a nice random password that you can then email to the user.