move mail-functions to external file