The best way to write a letter of recommendation is to start out with a formal greeting, or using "To whom it may concern" if you don’t know the recipient. Follow the greeting with 2-3 sentences of praise for the person you’re recommending.
Use a business closing and sign your name. Above all, be professional. If the you’re sending a physical letter, print it out and sign it by hand. Otherwise, just typing your name will do.