How can I send the passcode to the user via mail

In a customized scenario, we have created passcode for a user and now requirement is to send that passcode to user via mail.

Kindly suggest how it can be achieved.