Moved mail functions to API