move mail stuff to its own file