As banks lose money on mortgages and retreat from the business, PHH Corp. (PHH) is rushing to cash in.

PHH, the biggest U.S. outsourcer of home loans, processes and originates mortgages on behalf of small banks and some of the world’s largest financial firms, including Morgan Stanley and HSBC Holdings Plc. PHH Chief Executive Officer Glen Messina is so convinced he can make money where others can’t that in July he sold the company’s cash-producing fleet management unit and plans to plow the proceeds into mortgages.