Move email functionality to email module