Moved mail function to utils