If you are resigning from your job, you should not send out a farewell letter until you have notified your manager of your resignation. Sending out a farewell letter any time after that is acceptable.
Typically a farewell letter will be sent through e-mail and it should be sent in the business letter format, but without the heading (your return address, their address, and the date).
Farewell Letter Writing
You should try to keep overall tone of your letter positive and avoid any personal attacks or negative comments about the company.
The first paragraph should contain confirmation that you are leaving your job. Let your colleagues know when your last day will be. Use your own discretion on revealing why you are leaving and where you'll be going.
The next paragraph(s) should express your apprectiation about for your job. You can call out specific projects, assignments, or people that you are thankful for or learned from.
The last paragraph should conclude with the inclusion of your personal contact information. This may include your personal e-mail where you can be reached, your phone number, and/or a social media profile (e.g. Facebook or Linkedin).