Move mail to component. Add unit tests.